pub struct ConnectionPool { /* private fields */ }Expand description
Connection pool for HTTP connections.
Manages reusable HTTP connections to improve performance and reduce connection overhead.
§Thread Safety
The connection pool is thread-safe and can be shared across threads.
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
Sourcepub fn new(
max_connections_per_host: usize,
connection_timeout: Duration,
idle_timeout: Duration,
) -> Self
pub fn new( max_connections_per_host: usize, connection_timeout: Duration, idle_timeout: Duration, ) -> Self
Sourcepub fn get_or_create_connection(
&mut self,
host: &str,
) -> Result<Client, ClientError>
pub fn get_or_create_connection( &mut self, host: &str, ) -> Result<Client, ClientError>
Get or create a connection for a host.
Returns an existing connection if available, or creates a new one if needed. Automatically cleans up idle connections.
§Arguments
host- The host to get a connection for
§Returns
Returns a Client for the specified host.
§Errors
Returns an error if the connection cannot be created.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConnectionPool
impl !RefUnwindSafe for ConnectionPool
impl Send for ConnectionPool
impl Sync for ConnectionPool
impl Unpin for ConnectionPool
impl !UnwindSafe for ConnectionPool
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