DatabasePool

Trait DatabasePool 

Source
pub trait DatabasePool: Debug {
    type Connection: DatabaseConnector;
    type Config: DatabaseConfig;
    type Error: Debug + Error + Send + Sync + 'static;

    // Required method
    fn new_resource(
        config: &Self::Config,
        stale: Arc<AtomicBool>,
        timeout: Duration,
    ) -> Result<Self::Connection, Error<Self::Error>>;

    // Provided method
    fn drop(_resource: Self::Connection) { ... }
}
Expand description

Trait to manage resources

Required Associated Types§

Source

type Connection: DatabaseConnector

The resource to be pooled

Source

type Config: DatabaseConfig

The configuration that is needed in order to create the resource

Source

type Error: Debug + Error + Send + Sync + 'static

The error the resource may return when creating a new instance

Required Methods§

Source

fn new_resource( config: &Self::Config, stale: Arc<AtomicBool>, timeout: Duration, ) -> Result<Self::Connection, Error<Self::Error>>

Creates a new resource with a given config.

If stale is ever set to TRUE it is assumed the resource is no longer valid and it will be dropped.

Provided Methods§

Source

fn drop(_resource: Self::Connection)

The object is dropped

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§