pub trait AsyncConnectionFactory<T>: Send + Sync {
// Required method
fn create(&self) -> impl Future<Output = Result<T, FactoryError>> + Send;
// Provided methods
fn validate(&self, _conn: &T) -> impl Future<Output = bool> + Send { ... }
fn reset(
&self,
_conn: &T,
) -> impl Future<Output = Result<(), FactoryError>> + Send { ... }
fn close(
&self,
_conn: &T,
) -> impl Future<Output = Result<(), FactoryError>> + Send { ... }
fn is_fatal_error(&self, _err: &(dyn Error + 'static)) -> bool { ... }
}Expand description
Implement this to pool anything asynchronously. create must return a distinct object each
call (tracked by value identity).
Required Methods§
Provided Methods§
Sourcefn validate(&self, _conn: &T) -> impl Future<Output = bool> + Send
fn validate(&self, _conn: &T) -> impl Future<Output = bool> + Send
A cheap liveness check. Defaults to true.
Sourcefn reset(
&self,
_conn: &T,
) -> impl Future<Output = Result<(), FactoryError>> + Send
fn reset( &self, _conn: &T, ) -> impl Future<Output = Result<(), FactoryError>> + Send
Scrubs session state on release. Defaults to a no-op.
Sourcefn close(
&self,
_conn: &T,
) -> impl Future<Output = Result<(), FactoryError>> + Send
fn close( &self, _conn: &T, ) -> impl Future<Output = Result<(), FactoryError>> + Send
Disposes of a connection. Defaults to a no-op.
Sourcefn is_fatal_error(&self, _err: &(dyn Error + 'static)) -> bool
fn is_fatal_error(&self, _err: &(dyn Error + 'static)) -> bool
Whether err proves the connection is broken. Defaults to false.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".