Trait DatabasePool

Source
pub trait DatabasePool:
    Clone
    + Sync
    + Send {
    type TransactionType: Transaction;

    // Required methods
    fn read_transaction<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::TransactionType, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn transaction<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::TransactionType, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

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.

Required Associated Types§

Required Methods§

Source

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

Returns a Transaction for the database for which this DatabasePool has connections. If the database types offers specific read replicas, such as AWS Neptune, the connection is to a read replica. If no separate read replicas are offered, the connection is to the same endpoint that serves read/write requests.

§Errors

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

§Examples
let endpoint = CypherEndpoint::from_env()?;
let pool = endpoint.pool().await?;
let transaction = pool.read_transaction().await?;
Source

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

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 = CypherEndpoint::from_env()?;
let pool = endpoint.pool().await?;
let transaction = pool.transaction().await?;

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§