pub trait ManageConnection: Send + Sync + 'static {
    type Connection: Send + 'static;
    type Error: Error + Send;

    // Required methods
    fn connect<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<Self::Connection, L337Error<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_valid<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conn: &'life1 mut Self::Connection
    ) -> Pin<Box<dyn Future<Output = Result<(), L337Error<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn has_broken(&self, conn: &mut Self::Connection) -> bool;
    fn timed_out(&self) -> L337Error<Self::Error>;
}
Expand description

A trait which provides connection-specific functionality.

Required Associated Types§

source

type Connection: Send + 'static

The connection type this manager deals with.

source

type Error: Error + Send

The error type returned by Connections.

Required Methods§

source

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

Attempts to create a new connection.

Note that boxing is used here since impl Trait is not yet supported within trait definitions.

source

fn is_valid<'life0, 'life1, 'async_trait>( &'life0 self, conn: &'life1 mut Self::Connection ) -> Pin<Box<dyn Future<Output = Result<(), L337Error<Self::Error>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Determines if the connection is still connected to the database.

Note that boxing is used here since impl Trait is not yet supported within trait definitions.

source

fn has_broken(&self, conn: &mut Self::Connection) -> bool

Quick check to determine if the connection has broken

source

fn timed_out(&self) -> L337Error<Self::Error>

Produce an error representing a connection timeout.

Implementors§