pub trait RequestBuilderExt: Sized + Sealed {
// Required methods
fn json<T: Serialize + ?Sized>(
self,
value: &T,
) -> Result<Request<Bytes>, SetBodyError<Error>>;
fn form<T: Serialize + ?Sized>(
self,
form: &T,
) -> Result<Request<String>, SetBodyError<Error>>;
fn typed_header<T>(self, header: T) -> Self
where T: Header;
}
Expand description
Extension trait for the http::request::Builder
.
Required Methods§
Sourcefn json<T: Serialize + ?Sized>(
self,
value: &T,
) -> Result<Request<Bytes>, SetBodyError<Error>>
Available on crate feature json
only.
fn json<T: Serialize + ?Sized>( self, value: &T, ) -> Result<Request<Bytes>, SetBodyError<Error>>
json
only.Sets a JSON body for this request.
Additionally this method adds a CONTENT_TYPE
header for JSON body.
If you decide to override the request body, keep this in mind.
§Errors
If the given value’s implementation of serde::Serialize
decides to fail.
Sourcefn form<T: Serialize + ?Sized>(
self,
form: &T,
) -> Result<Request<String>, SetBodyError<Error>>
Available on crate feature form
only.
fn form<T: Serialize + ?Sized>( self, form: &T, ) -> Result<Request<String>, SetBodyError<Error>>
form
only.Sets a form body for this request.
Additionally this method adds a CONTENT_TYPE
header for form body.
If you decide to override the request body, keep this in mind.
§Errors
If the given value’s implementation of serde::Serialize
decides to fail.
Sourcefn typed_header<T>(self, header: T) -> Selfwhere
T: Header,
Available on crate feature typed_header
only.
fn typed_header<T>(self, header: T) -> Selfwhere
T: Header,
typed_header
only.Appends a typed header to this request.
This function will append the provided header as a header to the
internal http::HeaderMap
being constructed. Essentially this is
equivalent to calling headers::HeaderMapExt::typed_insert
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl RequestBuilderExt for Builder
impl RequestBuilderExt for Builder
Source§fn json<T: Serialize + ?Sized>(
self,
value: &T,
) -> Result<Request<Bytes>, SetBodyError<Error>>
fn json<T: Serialize + ?Sized>( self, value: &T, ) -> Result<Request<Bytes>, SetBodyError<Error>>
json
only.Source§fn form<T: Serialize + ?Sized>(
self,
form: &T,
) -> Result<Request<String>, SetBodyError<Error>>
fn form<T: Serialize + ?Sized>( self, form: &T, ) -> Result<Request<String>, SetBodyError<Error>>
form
only.Source§fn typed_header<T>(self, header: T) -> Selfwhere
T: Header,
fn typed_header<T>(self, header: T) -> Selfwhere
T: Header,
typed_header
only.