pub struct ClientBuilder { /* private fields */ }Expand description
Builder for Client.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
pub fn new() -> ClientBuilder
pub fn base_url(self, base_url: impl AsRef<str>) -> Result<ClientBuilder, Error>
pub fn timeout(self, timeout: Duration) -> ClientBuilder
pub fn retry(self, policy: RetryPolicy) -> ClientBuilder
pub fn auth(self, auth: Auth) -> ClientBuilder
pub fn default_header( self, key: impl AsRef<str>, value: impl AsRef<str>, ) -> Result<ClientBuilder, Error>
pub fn hooks(self, hooks: Hooks) -> ClientBuilder
pub fn plugin<P>(self, plugin: P) -> ClientBuilderwhere
P: Plugin + 'static,
pub fn reqwest_client(self, client: Client) -> ClientBuilder
Sourcepub fn backend(self, backend: Arc<dyn HttpBackend>) -> ClientBuilder
pub fn backend(self, backend: Arc<dyn HttpBackend>) -> ClientBuilder
Use a custom HTTP backend (for testing or alternate transports).
Sourcepub fn max_in_flight(self, limit: usize) -> ClientBuilder
pub fn max_in_flight(self, limit: usize) -> ClientBuilder
Limits how many requests this client may have in flight at once (including retries).
Implemented with a tokio semaphore in the core client; does not require the tower feature.
For token-bucket rate limiting or richer policies, use [Self::transport_stack] with
Tower layers (feature tower).
Sourcepub fn json_parser<F>(self, f: F) -> ClientBuilder
pub fn json_parser<F>(self, f: F) -> ClientBuilder
Sets a custom JSON parser for all responses from this client.
The parser receives raw response bytes and must return a serde_json::Value.
Typed deserialization (json, send_json) then uses serde to map that value to T.
Sourcepub fn json_parser_fn(
self,
parser: Arc<dyn Fn(&Bytes) -> Result<Value, String> + Sync + Send>,
) -> ClientBuilder
pub fn json_parser_fn( self, parser: Arc<dyn Fn(&Bytes) -> Result<Value, String> + Sync + Send>, ) -> ClientBuilder
Sets a custom JSON parser from an existing JsonParserFn.
pub fn build(self) -> Result<Client, Error>
Trait Implementations§
Source§impl Default for ClientBuilder
impl Default for ClientBuilder
Source§fn default() -> ClientBuilder
fn default() -> ClientBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ClientBuilder
impl !RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnsafeUnpin for ClientBuilder
impl !UnwindSafe for ClientBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more