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§
Sourcetype Connection: DatabaseConnector
type Connection: DatabaseConnector
The resource to be pooled
Sourcetype Config: DatabaseConfig
type Config: DatabaseConfig
The configuration that is needed in order to create the resource
Required Methods§
Sourcefn new_resource(
config: &Self::Config,
stale: Arc<AtomicBool>,
timeout: Duration,
) -> Result<Self::Connection, Error<Self::Error>>
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§
Sourcefn drop(_resource: Self::Connection)
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.