[][src]Struct sqlx::Pool

pub struct Pool<DB>(_)
where
    DB: Database
;

An asynchronous pool of SQLx database connections.

Implementations

impl<DB> Pool<DB> where
    DB: Database
[src]

pub async fn connect(uri: &'_ str) -> Result<Pool<DB>, Error>[src]

Creates a new connection pool with a default pool configuration and the given connection URI; and, immediately establishes one connection.

pub async fn connect_with(
    options: <<DB as Database>::Connection as Connection>::Options
) -> Result<Pool<DB>, Error>
[src]

Creates a new connection pool with a default pool configuration and the given connection options; and, immediately establishes one connection.

pub fn connect_lazy(uri: &str) -> Result<Pool<DB>, Error>[src]

Creates a new connection pool with a default pool configuration and the given connection URI; and, will establish a connections as the pool starts to be used.

pub fn connect_lazy_with(
    options: <<DB as Database>::Connection as Connection>::Options
) -> Pool<DB>
[src]

Creates a new connection pool with a default pool configuration and the given connection options; and, will establish a connections as the pool starts to be used.

pub fn acquire(
    &self
) -> impl Future<Output = Result<PoolConnection<DB>, Error>> + 'static
[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<DB>>[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<'static, DB>, Error>[src]

Retrieves a new connection and immediately begins a new transaction.

pub async fn try_begin(
    &'_ self
) -> Result<Option<Transaction<'static, DB>>, Error>
[src]

Attempts to retrieve a new connection and immediately begins a new transaction if there is one available.

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.

Trait Implementations

impl<'_, DB> Acquire<'static> for &'_ Pool<DB> where
    DB: Database
[src]

type Database = DB

type Connection = PoolConnection<DB>

impl<DB> Clone for Pool<DB> where
    DB: Database
[src]

Returns a new Pool tied to the same shared connection pool.

impl<DB> Debug for Pool<DB> where
    DB: Database
[src]

impl<'p, '_, DB> Executor<'p> for &'_ Pool<DB> where
    DB: Database,
    &'c mut <DB as Database>::Connection: for<'c> Executor<'c>,
    <&'c mut <DB as Database>::Connection as Executor<'c>>::Database == DB, 
[src]

type Database = DB

Auto Trait Implementations

impl<DB> !RefUnwindSafe for Pool<DB>

impl<DB> Send for Pool<DB> where
    <DB as Database>::Connection: Send,
    <<DB as Database>::Connection as Connection>::Options: Send + Sync

impl<DB> Sync for Pool<DB> where
    <DB as Database>::Connection: Send,
    <<DB as Database>::Connection as Connection>::Options: Send + Sync

impl<DB> Unpin for Pool<DB>

impl<DB> !UnwindSafe for Pool<DB>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,