Trait ManageConnection

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

    // Required methods
    fn connect(
        &self,
    ) -> impl Future<Output = Result<Self::Connection, Self::Error>> + Send;
    fn is_valid(
        &self,
        conn: &mut Self::Connection,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn has_broken(&self, conn: &mut Self::Connection) -> bool;
}
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: Debug + Send + 'static

The error type returned by Connections.

Required Methods§

Source

fn connect( &self, ) -> impl Future<Output = Result<Self::Connection, Self::Error>> + Send

Attempts to create a new connection.

Source

fn is_valid( &self, conn: &mut Self::Connection, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Determines if the connection is still connected to the database.

Source

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

Synchronously determine if the connection is no longer usable, if possible.

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§