pub trait Poolable: Send + 'static {
type Error: Error + Send + Sync + 'static;
// Required methods
fn connect(
addr: &str,
user: &str,
password: &str,
database: &str,
) -> impl Future<Output = Result<Self, Self::Error>> + Send
where Self: Sized;
fn has_pending_data(&self) -> bool;
// Provided method
fn reset(&self) -> impl Future<Output = bool> + Send { ... }
}Expand description
Trait for connection types that can be managed by the pool.
Required Associated Types§
Required Methods§
Sourcefn connect(
addr: &str,
user: &str,
password: &str,
database: &str,
) -> impl Future<Output = Result<Self, Self::Error>> + Sendwhere
Self: Sized,
fn connect(
addr: &str,
user: &str,
password: &str,
database: &str,
) -> impl Future<Output = Result<Self, Self::Error>> + Sendwhere
Self: Sized,
Create a new connection to the database.
Sourcefn has_pending_data(&self) -> bool
fn has_pending_data(&self) -> bool
Check if the connection has unconsumed data (is in a corrupted state).
Provided Methods§
Sourcefn reset(&self) -> impl Future<Output = bool> + Send
fn reset(&self) -> impl Future<Output = bool> + Send
Reset the connection to a clean state before returning to the pool.
Implementations should send DISCARD ALL or equivalent to clear
session state (transactions, SET variables, temp tables, prepared statements).
Returns false if the reset failed and the connection should be destroyed.
Must not panic. A panic in reset() will cause the spawned return
task to abort, but in_use_count is decremented before reset() is
called so the pool remains consistent.
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.