DatabasePool

Trait DatabasePool 

Source
pub trait DatabasePool: Send + Sync {
    // Required methods
    fn acquire<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = OrmResult<Box<dyn DatabaseConnection>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn begin_transaction<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = OrmResult<Box<dyn DatabaseTransaction>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn execute<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        sql: &'life1 str,
        params: &'life2 [DatabaseValue],
    ) -> Pin<Box<dyn Future<Output = OrmResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn fetch_all<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        sql: &'life1 str,
        params: &'life2 [DatabaseValue],
    ) -> Pin<Box<dyn Future<Output = OrmResult<Vec<Box<dyn DatabaseRow>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn fetch_optional<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        sql: &'life1 str,
        params: &'life2 [DatabaseValue],
    ) -> Pin<Box<dyn Future<Output = OrmResult<Option<Box<dyn DatabaseRow>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stats(&self) -> DatabasePoolStats;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = OrmResult<Duration>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Abstract database connection pool trait

Required Methods§

Source

fn acquire<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = OrmResult<Box<dyn DatabaseConnection>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Acquire a connection from the pool

Source

fn begin_transaction<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = OrmResult<Box<dyn DatabaseTransaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Begin a transaction from the pool

Source

fn execute<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, sql: &'life1 str, params: &'life2 [DatabaseValue], ) -> Pin<Box<dyn Future<Output = OrmResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Execute a query directly on the pool

Source

fn fetch_all<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, sql: &'life1 str, params: &'life2 [DatabaseValue], ) -> Pin<Box<dyn Future<Output = OrmResult<Vec<Box<dyn DatabaseRow>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Execute a query and return result rows directly on the pool

Source

fn fetch_optional<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, sql: &'life1 str, params: &'life2 [DatabaseValue], ) -> Pin<Box<dyn Future<Output = OrmResult<Option<Box<dyn DatabaseRow>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Execute a query and return the first result row directly on the pool

Source

fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = OrmResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close the pool

Source

fn stats(&self) -> DatabasePoolStats

Get pool statistics

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = OrmResult<Duration>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform a health check on the pool

Implementors§