#[non_exhaustive]pub struct HttpClientPolicy { /* private fields */ }Expand description
Shared HTTP client policy used by transport-owning crates.
Implementations§
Source§impl HttpClientPolicy
impl HttpClientPolicy
Sourcepub fn new(user_agent: impl Into<String>) -> Result<Self, ValidationError>
pub fn new(user_agent: impl Into<String>) -> Result<Self, ValidationError>
Creates a policy with the default timeout and a validated user agent.
§Errors
Returns ValidationError if the user agent is empty or cannot be
encoded as an HTTP header value.
Sourcepub fn with_timeout_and_user_agent(
timeout: Duration,
user_agent: impl Into<String>,
) -> Result<Self, ValidationError>
pub fn with_timeout_and_user_agent( timeout: Duration, user_agent: impl Into<String>, ) -> Result<Self, ValidationError>
Creates a policy with an explicit timeout and validated user agent.
§Errors
Returns ValidationError if the user agent is empty or cannot be
encoded as an HTTP header value.
Sourcepub const fn without_timeout(self) -> Self
pub const fn without_timeout(self) -> Self
Returns a copy of this policy with timeouts disabled.
Sourcepub const fn with_timeout(self, timeout: Duration) -> Self
pub const fn with_timeout(self, timeout: Duration) -> Self
Returns a copy of this policy with the supplied timeout.
Sourcepub const fn with_max_response_bytes(self, max_response_bytes: usize) -> Self
pub const fn with_max_response_bytes(self, max_response_bytes: usize) -> Self
Returns a copy of this policy with the supplied maximum response-body size, in bytes. The HTTP transport refuses to buffer a response whose decoded body would exceed this many bytes.
Sourcepub fn try_with_user_agent(
self,
user_agent: impl Into<String>,
) -> Result<Self, ValidationError>
pub fn try_with_user_agent( self, user_agent: impl Into<String>, ) -> Result<Self, ValidationError>
Returns a copy of this policy with a newly validated user agent.
§Errors
Returns ValidationError if the user agent is empty or cannot be
encoded as an HTTP header value.
Sourcepub const fn timeout(&self) -> Option<Duration>
pub const fn timeout(&self) -> Option<Duration>
Returns the configured timeout, if one is enabled.
Sourcepub const fn max_response_bytes(&self) -> usize
pub const fn max_response_bytes(&self) -> usize
Returns the configured maximum response-body size, in bytes.
Sourcepub fn user_agent(&self) -> &str
pub fn user_agent(&self) -> &str
Returns the configured user-agent header value.
Trait Implementations§
Source§impl Clone for HttpClientPolicy
impl Clone for HttpClientPolicy
Source§fn clone(&self) -> HttpClientPolicy
fn clone(&self) -> HttpClientPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HttpClientPolicy
impl Debug for HttpClientPolicy
impl Eq for HttpClientPolicy
Source§impl PartialEq for HttpClientPolicy
impl PartialEq for HttpClientPolicy
Source§fn eq(&self, other: &HttpClientPolicy) -> bool
fn eq(&self, other: &HttpClientPolicy) -> bool
self and other values to be equal, and is used by ==.