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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> IntoSql for T
impl<T> IntoSql for T
sourcefn into_sql<T>(self) -> AsExprOf<Self, T>where
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
fn into_sql<T>(self) -> AsExprOf<Self, T>where
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
self
to an expression for Diesel’s query builder. Read moresourcefn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>where
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>where
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
&self
to an expression for Diesel’s query builder. Read more