[−][src]Struct sqlx_core::pool::Pool
A pool of database connections.
Methods
impl<C> Pool<C> where
C: Connect, [src]
C: Connect,
pub async fn new<'_>(url: &'_ str) -> Result<Self>[src]
Creates a connection pool with the default configuration.
The connection URL syntax is documented on the connection type for the respective database you're connecting to:
- MySQL/MariaDB: [crate::mysql::MySqlConnection]
- PostgreSQL: [crate::postgres::PgConnection]
pub fn builder() -> Builder<C>[src]
Returns a Builder to configure a new connection pool.
pub async fn acquire<'_>(&'_ self) -> Result<PoolConnection<C>>[src]
Retrieves a connection from the pool.
Waits for at most the configured connection timeout before returning an error.
pub fn try_acquire(&self) -> Option<PoolConnection<C>>[src]
Attempts to retrieve a connection from the pool if there is one available.
Returns None immediately if there are no idle connections available in the pool.
pub async fn begin<'_>(&'_ self) -> Result<Transaction<PoolConnection<C>>>[src]
Retrieves a new connection and immediately begins a new transaction.
pub async fn close<'_>(&'_ self)[src]
Ends the use of a connection pool. Prevents any new connections and will close all active connections when they are returned to the pool.
Does not resolve until all connections are closed.
pub fn is_closed(&self) -> bool[src]
Returns true if .close() has been called on the pool, false otherwise.
pub fn size(&self) -> u32[src]
Returns the number of connections currently being managed by the pool.
pub fn idle(&self) -> usize[src]
Returns the number of idle connections.
pub fn max_size(&self) -> u32[src]
Returns the configured maximum pool size.
pub fn connect_timeout(&self) -> Duration[src]
Returns the maximum time spent acquiring a new connection before an error is returned.
pub fn min_size(&self) -> u32[src]
Returns the configured minimum idle connection count.
pub fn max_lifetime(&self) -> Option<Duration>[src]
Returns the configured maximum connection lifetime.
pub fn idle_timeout(&self) -> Option<Duration>[src]
Returns the configured idle connection timeout.
Trait Implementations
impl<C> Clone for Pool<C>[src]
Returns a new Pool tied to the same shared connection pool.
fn clone(&self) -> Self[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<C> Debug for Pool<C> where
C: Connect, [src]
C: Connect,
impl<'p, C, DB> Executor for &'p Pool<C> where
C: Connect<Database = DB>,
DB: Database<Connection = C>,
DB: for<'c, 'q> HasCursor<'c, 'q, Database = DB>, [src]
C: Connect<Database = DB>,
DB: Database<Connection = C>,
DB: for<'c, 'q> HasCursor<'c, 'q, Database = DB>,
type Database = DB
The specific database that this type is implemented for.
fn execute<'e, 'q: 'e, 'c: 'e, E: 'e>(
&'c mut self,
query: E
) -> BoxFuture<'e, Result<u64>> where
E: Execute<'q, Self::Database>, [src]
&'c mut self,
query: E
) -> BoxFuture<'e, Result<u64>> where
E: Execute<'q, Self::Database>,
fn fetch<'e, 'q, E>(
&'e mut self,
query: E
) -> <Self::Database as HasCursor<'_, 'q>>::Cursor where
E: Execute<'q, DB>, [src]
&'e mut self,
query: E
) -> <Self::Database as HasCursor<'_, 'q>>::Cursor where
E: Execute<'q, DB>,
impl<'p, C, DB> RefExecutor<'p> for &'p Pool<C> where
C: Connect<Database = DB>,
DB: Database<Connection = C>,
DB: for<'c, 'q> HasCursor<'c, 'q>,
&'c mut C: RefExecutor<'c>, [src]
C: Connect<Database = DB>,
DB: Database<Connection = C>,
DB: for<'c, 'q> HasCursor<'c, 'q>,
&'c mut C: RefExecutor<'c>,
Auto Trait Implementations
impl<C> !RefUnwindSafe for Pool<C>
impl<C> Send for Pool<C> where
C: Send,
C: Send,
impl<C> Sync for Pool<C> where
C: Send,
C: Send,
impl<C> Unpin for Pool<C>
impl<C> !UnwindSafe for Pool<C>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,