Trait warpgrapher::engine::database::DatabaseEndpoint
source · [−]pub trait DatabaseEndpoint {
type PoolType: DatabasePool;
fn pool<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::PoolType, Error>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
Trait for a database endpoint. Structs that implement this trait typically take in a connection string and produce a database pool of clients connected to the database
Associated Types
type PoolType: DatabasePool
Required methods
Returns a DatabasePool
to the database for which this DatabaseEndpoint has connection
information
Errors
Returns an Error
if the database pool cannot be built, for example if the database
connection information in the implementation of the DatabaseEndpoint does not successfully
connect to a database. The specific Error
variant depends on the database back-end.
Examples
let mut runtime = Runtime::new()?;
let endpoint = CypherEndpoint::from_env()?;
let pool = runtime.block_on(endpoint.pool())?;