pub struct ClientBuilder { /* private fields */ }Expand description
Builder for constructing a Client with custom configuration.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder with defaults (30s timeout, 3 retries, exponential backoff).
Sourcepub fn base_url(self, url: impl Into<String>) -> Self
pub fn base_url(self, url: impl Into<String>) -> Self
Set a base URL that is prepended to all relative paths.
Sourcepub fn retry_bounds(self, initial: Duration, max: Duration) -> Self
pub fn retry_bounds(self, initial: Duration, max: Duration) -> Self
Set the initial and maximum retry backoff durations.
Sourcepub fn default_header(self, key: &'static str, value: &'static str) -> Self
pub fn default_header(self, key: &'static str, value: &'static str) -> Self
Add a default header applied to every request (infallible for compile-time string literals).
§Panics
Panics if key or value is not a valid HTTP header string —
this is a caller programming error, not a runtime condition.
Use default_headers with a HeaderMap
for a fallible variant.
Sourcepub fn default_headers(self, headers: HeaderMap) -> Self
pub fn default_headers(self, headers: HeaderMap) -> Self
Set multiple default headers applied to every request.
Sourcepub fn user_agent(self, agent: &'static str) -> Self
pub fn user_agent(self, agent: &'static str) -> Self
Set the User-Agent header.
Sourcepub fn reqwest_builder(self, builder: ClientBuilder) -> Self
pub fn reqwest_builder(self, builder: ClientBuilder) -> Self
Add a raw reqwest::ClientBuilder for advanced configuration.
Sourcepub fn try_build(self) -> Result<Client, FetchError>
pub fn try_build(self) -> Result<Client, FetchError>
Build the Client, returning a FetchError on failure.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ClientBuilder
impl !UnwindSafe for ClientBuilder
impl Freeze for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnsafeUnpin 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