pub trait Manager: Send + Sync + 'static {
type Connection: Send + 'static;
type Error: Send + Sync + 'static;
// Required methods
fn connect<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn check<'life0, 'async_trait>(
&'life0 self,
conn: Self::Connection
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn spawn_task<T>(&self, task: T)
where T: Future + Send + 'static,
T::Output: Send + 'static { ... }
fn validate(&self, _conn: &mut Self::Connection) -> bool { ... }
}
Expand description
A trait which provides connection-specific functionality.
Required Associated Types§
sourcetype Connection: Send + 'static
type Connection: Send + 'static
The connection type this manager deals with.
Required Methods§
sourcefn connect<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Attempts to create a new connection.
sourcefn check<'life0, 'async_trait>(
&'life0 self,
conn: Self::Connection
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn check<'life0, 'async_trait>( &'life0 self, conn: Self::Connection ) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Determines if the connection is still connected to the database when check-out.
A standard implementation would check if a simple query like SELECT 1
succeeds.
Provided Methods§
sourcefn spawn_task<T>(&self, task: T)where
T: Future + Send + 'static,
T::Output: Send + 'static,
fn spawn_task<T>(&self, task: T)where T: Future + Send + 'static, T::Output: Send + 'static,
Spawns a new asynchronous task.
sourcefn validate(&self, _conn: &mut Self::Connection) -> bool
fn validate(&self, _conn: &mut Self::Connection) -> bool
Quickly determines a connection is still valid when check-in.
Object Safety§
This trait is not object safe.