pub struct Pool<M>(_)
where
M: ManageConnection;
Expand description
A generic connection pool.
Implementations
sourceimpl<M> Pool<M> where
M: ManageConnection,
impl<M> Pool<M> where
M: ManageConnection,
sourcepub fn new(manager: M) -> Result<Pool<M>, Error>
pub fn new(manager: M) -> Result<Pool<M>, Error>
Creates a new connection pool with a default configuration.
sourcepub fn get(&self) -> Result<PooledConnection<M>, Error>
pub fn get(&self) -> Result<PooledConnection<M>, Error>
Retrieves a connection from the pool.
Waits for at most the configured connection timeout before returning an error.
sourcepub fn get_timeout(
&self,
timeout: Duration
) -> Result<PooledConnection<M>, Error>
pub fn get_timeout(
&self,
timeout: Duration
) -> Result<PooledConnection<M>, Error>
Retrieves a connection from the pool, waiting for at most timeout
The given timeout will be used instead of the configured connection timeout.
sourcepub fn try_get(&self) -> Option<PooledConnection<M>>
pub fn try_get(&self) -> Option<PooledConnection<M>>
Attempts to retrieve a connection from the pool if there is one available.
Returns None
if there are no idle connections available in the pool.
This method will not block waiting to establish a new connection.
sourcepub fn test_on_check_out(&self) -> bool
pub fn test_on_check_out(&self) -> bool
Returns if the pool is configured to test connections on check out.
sourcepub fn max_lifetime(&self) -> Option<Duration>
pub fn max_lifetime(&self) -> Option<Duration>
Returns the configured maximum connection lifetime.
sourcepub fn idle_timeout(&self) -> Option<Duration>
pub fn idle_timeout(&self) -> Option<Duration>
Returns the configured idle connection timeout.
sourcepub fn connection_timeout(&self) -> Duration
pub fn connection_timeout(&self) -> Duration
Returns the configured connection timeout.
Trait Implementations
sourceimpl<M> Clone for Pool<M> where
M: ManageConnection,
impl<M> Clone for Pool<M> where
M: ManageConnection,
Returns a new Pool
referencing the same state as self
.
Auto Trait Implementations
impl<M> !RefUnwindSafe for Pool<M>
impl<M> Send for Pool<M>
impl<M> Sync for Pool<M>
impl<M> Unpin for Pool<M>
impl<M> !UnwindSafe for Pool<M>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more