pub struct HttpClientConfig { /* private fields */ }Expand description
How a client is told to behave.
§Examples
use std::time::Duration;
use protocol_droid::adapters::secondary::transport::http::{
HttpClient, HttpClientConfig, Resumable, RetryBudget,
};
let config = HttpClientConfig::new("https://example.invalid/mcp")?
.with_request_timeout(Duration::from_secs(30));
// Building a client opens no socket; the first call does.
let _client = HttpClient::new(config)?;
let _policy = Resumable {
budget: RetryBudget::new(3),
};Implementations§
Source§impl HttpClientConfig
impl HttpClientConfig
Sourcepub fn new(endpoint: &str) -> Result<Self, HttpClientError>
pub fn new(endpoint: &str) -> Result<Self, HttpClientError>
A configuration pointed at endpoint.
§Errors
HttpClientError::Url if endpoint is not a URL a request can be
built against. Checked here rather than at the first call, so a typo is
a construction error and not a surprise on the wire.
Sourcepub const fn with_request_timeout(self, timeout: Duration) -> Self
pub const fn with_request_timeout(self, timeout: Duration) -> Self
Bounds how long one request may take, reading its body included.
Sourcepub const fn without_request_timeout(self) -> Self
pub const fn without_request_timeout(self) -> Self
Removes the request timeout, so a stream may stay open indefinitely.
The default is no timeout, because a streamable event stream is long-lived by definition and a timeout on one is a reconnect loop.
Sourcepub const fn request_timeout(&self) -> Option<Duration>
pub const fn request_timeout(&self) -> Option<Duration>
The request timeout, if one is set.
Trait Implementations§
Source§impl Clone for HttpClientConfig
impl Clone for HttpClientConfig
Auto Trait Implementations§
impl Freeze for HttpClientConfig
impl RefUnwindSafe for HttpClientConfig
impl Send for HttpClientConfig
impl Sync for HttpClientConfig
impl Unpin for HttpClientConfig
impl UnsafeUnpin for HttpClientConfig
impl UnwindSafe for HttpClientConfig
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