Trait warpgrapher::engine::database::DatabasePool[][src]

pub trait DatabasePool: Clone + Sync + Send {
    type TransactionType: Transaction;
#[must_use]    fn transaction<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<Self::TransactionType, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn client<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<DatabaseClient, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; }

Trait for a database pool. Structs that implement this trait are created by a database endpoint and provide a way to get a transaction from the pool.

Associated Types

Loading content...

Required methods

#[must_use]fn transaction<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::TransactionType, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Returns a Transaction for the database for which this DatabasePool has connections

Errors

Returns an Error if the transaction cannot be created. The specific Error variant depends on the database back-end.

Examples

let endpoint = Neo4jEndpoint::from_env()?;
let pool = endpoint.pool().await?;
let transaction = pool.transaction().await?;

#[must_use]fn client<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<DatabaseClient, Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Returns a DatabaseClient for the database for which this DatabasePool has connections

Errors

Returns an Error if the client cannot be obtained from the pool. The specific Error variant depends on the database back-end.

Examples

let endpoint = Neo4jEndpoint::from_env()?;
let pool = endpoint.pool().await?;
let client = pool.client().await?;
Loading content...

Implementors

impl DatabasePool for NoDatabasePool[src]

type TransactionType = NoTransaction

Loading content...