pub struct RequestBuilder { /* private fields */ }
Expand description
A builder to construct the properties of a Request
.
To construct a RequestBuilder
, refer to the Client
documentation.
Implementations§
source§impl RequestBuilder
impl RequestBuilder
sourcepub fn header<K, V>(self, key: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
pub fn header<K, V>(self, key: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
Add a Header
to this Request.
This method allows you to add a single header to the request.
sourcepub fn headers(self, headers: HeaderMap) -> Self
pub fn headers(self, headers: HeaderMap) -> Self
Add a set of Headers to the existing ones on this Request.
This method merges the provided headers with any already set on the request.
sourcepub fn body<T: Into<Body>>(self, body: T) -> Self
pub fn body<T: Into<Body>>(self, body: T) -> Self
Set the request body.
This method sets the body of the request to the provided value.
sourcepub fn json<T: Serialize + ?Sized>(self, json: &T) -> Self
pub fn json<T: Serialize + ?Sized>(self, json: &T) -> Self
Send a JSON body.
This method serializes the provided data structure as JSON and sets it as the request body.
§Errors
Serialization can fail if T
’s implementation of Serialize
decides to
fail, or if T
contains a map with non-string keys.
sourcepub fn redact(self, redact: String) -> Self
pub fn redact(self, redact: String) -> Self
Add a Redact instruction.
This method adds a header to instruct Verity Prover on how to hide sensitive data.
sourcepub fn build(self) -> Result<Request>
pub fn build(self) -> Result<Request>
Build a Request
.
This method constructs the request, which can then be
inspected, modified and executed with VerityClient::execute()
.
sourcepub fn build_split(self) -> (VerityClient, Result<Request>)
pub fn build_split(self) -> (VerityClient, Result<Request>)
Build a Request
, which can be inspected, modified and executed with
VerityClient::execute()
.
This is similar to RequestBuilder::build()
, but also returns the
embedded VerityClient
.
sourcepub async fn send(self) -> Result<VerityResponse>
pub async fn send(self) -> Result<VerityResponse>
Constructs the Request and sends it to the target URL, returning a future Response.
§Errors
This method fails if there was an error while sending request, redirect loop was detected or redirect limit was exhausted.
§Example
let config = VerityClientConfig {
prover_url: String::from("http://127.0.0.1:8080"),
};
let response = VerityClient::new(config)
.get("https://hyper.rs")
.send()
.await?;