DatabaseBackend

Trait DatabaseBackend 

Source
pub trait DatabaseBackend: Send + Sync {
    // Required methods
    fn connect<'life0, 'async_trait>(
        url: &'life0 str,
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        sql: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn query<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        sql: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<QueryResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn begin_transaction<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn commit<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn rollback<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_connected(&self) -> bool;
    fn close<'async_trait>(
        self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

Database backend trait

Required Methods§

Source

fn connect<'life0, 'async_trait>( url: &'life0 str, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait,

Connect to the database

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 mut self, sql: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute a SQL statement (no results)

Source

fn query<'life0, 'life1, 'async_trait>( &'life0 mut self, sql: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<QueryResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Query and return results

Source

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

Begin a transaction

Source

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

Commit the current transaction

Source

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

Rollback the current transaction

Source

fn is_connected(&self) -> bool

Check if connected

Source

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

Close the connection

Implementors§