Trait RequestBuilder

Source
pub trait RequestBuilder: Debug {
    type ReturnValue;
    type ClientBuilder;

    // Required methods
    fn new(method: Method, url: &str, client: &Self::ClientBuilder) -> Self;
    fn body(self, b: String) -> Self;
    fn header<K, V>(self, key: K, val: V) -> Self
       where HeaderName: TryFrom<K>,
             HeaderValue: TryFrom<V>,
             <HeaderName as TryFrom<K>>::Error: Into<Error>,
             <HeaderValue as TryFrom<V>>::Error: Into<Error>;
    fn send(self) -> Result<Self::ReturnValue, Error>
       where Self: Sized;
}
Expand description

A generic request builder. Allows you to use any HTTP client. See DefaultRequestBuilder for one that uses reqwest::Client.

Required Associated Types§

Source

type ReturnValue

Generic return value allows you to return a future, allowing the possibility of using this library in async environments.

Source

type ClientBuilder

This is useful for reusing existing connection pools.

Required Methods§

Source

fn new(method: Method, url: &str, client: &Self::ClientBuilder) -> Self

Construct the request builder

Source

fn body(self, b: String) -> Self

Set the body

Source

fn header<K, V>(self, key: K, val: V) -> Self

Set a header

Source

fn send(self) -> Result<Self::ReturnValue, Error>
where Self: Sized,

A build-like function that also sends the request

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.

Implementors§

Source§

impl RequestBuilder for DefaultRequestBuilder

Available on crate feature reqwest-blocking only.