Trait RequestBuilderExt

Source
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§

Source

fn json<T: Serialize + ?Sized>( self, value: &T, ) -> Result<Request<Bytes>, SetBodyError<Error>>

Available on crate feature 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.

Source

fn form<T: Serialize + ?Sized>( self, form: &T, ) -> Result<Request<String>, SetBodyError<Error>>

Available on crate feature 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.

Source

fn typed_header<T>(self, header: T) -> Self
where T: Header,

Available on crate feature 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

Source§

fn json<T: Serialize + ?Sized>( self, value: &T, ) -> Result<Request<Bytes>, SetBodyError<Error>>

Available on crate feature json only.
Source§

fn form<T: Serialize + ?Sized>( self, form: &T, ) -> Result<Request<String>, SetBodyError<Error>>

Available on crate feature form only.
Source§

fn typed_header<T>(self, header: T) -> Self
where T: Header,

Available on crate feature typed_header only.

Implementors§