pub struct SurfPool { /* private fields */ }Expand description
The main struct, used to get a valid connection
Implementations§
Source§impl SurfPool
impl SurfPool
pub fn get_pool_size(&self) -> usize
Sourcepub async fn get_handler(&self) -> Option<Handler>
pub async fn get_handler(&self) -> Option<Handler>
This function return an handler representing a potential connection
available in the pool.
The handler is not a connection, but a Surf client can be obtained
via [get_client]
If the pool is empty, the function will wait until an handler is
available again
To not starve other clients, it’s important to drop the handler after
it has been used
The return type is an Option, but it should never return None,
the system is designed in a way that, once unblocked, at least one
resources should be available
use surf_pool::SurfPoolBuilder;
let builder = SurfPoolBuilder::new(3).unwrap();
let pool = builder.build().await;
let handler = pool.get_handler().await.unwrap();Trait Implementations§
Auto Trait Implementations§
impl Freeze for SurfPool
impl !RefUnwindSafe for SurfPool
impl Send for SurfPool
impl Sync for SurfPool
impl Unpin for SurfPool
impl !UnwindSafe for SurfPool
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