[−][src]Struct sqlx::Pool
A pool of database connections.
Methods
impl<DB> Pool<DB> where
DB: Database,
<DB as Database>::Connection: Connection,
<<DB as Database>::Connection as Executor>::Database == DB,
[src]
DB: Database,
<DB as Database>::Connection: Connection,
<<DB as Database>::Connection as Executor>::Database == DB,
pub async fn new(url: &'_ str) -> Result<Pool<DB>, Error>
[src]
Creates a connection pool with the default configuration.
pub fn builder() -> Builder<DB>
[src]
Returns a [Builder] to configure a new connection pool.
pub async fn acquire(&'_ self) -> Result<impl DerefMut, Error>
[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<impl DerefMut>
[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 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 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<DB> Clone for Pool<DB> where
DB: Database,
[src]
DB: Database,
Returns a new Pool tied to the same shared connection pool.
impl<'_, DB> Executor for &'_ Pool<DB> where
DB: Database,
[src]
DB: Database,
type Database = DB
fn send<'e, 'q>(
&'e mut self,
commands: &'q str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
commands: &'q str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'e + Send>> where
'q: 'e,
fn execute<'e, 'q>(
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'e + Send>> where
'q: 'e,
fn fetch<'e, 'q>(
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
fn fetch_optional<'e, 'q>(
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<Option<<DB as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<Option<<DB as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
fn describe<'e, 'q>(
&'e mut self,
query: &'q str
) -> Pin<Box<dyn Future<Output = Result<Describe<<&'_ Pool<DB> as Executor>::Database>, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str
) -> Pin<Box<dyn Future<Output = Result<Describe<<&'_ Pool<DB> as Executor>::Database>, Error>> + 'e + Send>> where
'q: 'e,
fn fetch_one<'e, 'q>(
&'e mut self,
query: &'q str,
args: <Self::Database as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str,
args: <Self::Database as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
impl<DB> Executor for Pool<DB> where
DB: Database,
[src]
DB: Database,
type Database = DB
fn send<'e, 'q>(
&'e mut self,
commands: &'q str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
commands: &'q str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'e + Send>> where
'q: 'e,
fn execute<'e, 'q>(
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'e + Send>> where
'q: 'e,
fn fetch<'e, 'q>(
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
fn fetch_optional<'e, 'q>(
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<Option<<DB as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str,
args: <DB as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<Option<<DB as Database>::Row>, Error>> + 'e + Send>> where
'q: 'e,
fn describe<'e, 'q>(
&'e mut self,
query: &'q str
) -> Pin<Box<dyn Future<Output = Result<Describe<<Pool<DB> as Executor>::Database>, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str
) -> Pin<Box<dyn Future<Output = Result<Describe<<Pool<DB> as Executor>::Database>, Error>> + 'e + Send>> where
'q: 'e,
fn fetch_one<'e, 'q>(
&'e mut self,
query: &'q str,
args: <Self::Database as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
[src]
&'e mut self,
query: &'q str,
args: <Self::Database as Database>::Arguments
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
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: Send,
impl<DB> Sync for Pool<DB> where
<DB as Database>::Connection: Send,
<DB as Database>::Connection: Send,
impl<DB> Unpin for Pool<DB>
impl<DB> !UnwindSafe for Pool<DB>
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, DB> HasSqlType<&'_ T> for DB where
DB: HasSqlType<T>,
T: ?Sized,
[src]
DB: HasSqlType<T>,
T: ?Sized,
fn metadata() -> <DB as HasTypeMetadata>::TypeMetadata
[src]
impl<T, DB> HasSqlType<Option<T>> for DB where
DB: HasSqlType<T>,
[src]
DB: HasSqlType<T>,
fn metadata() -> <DB as HasTypeMetadata>::TypeMetadata
[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>,