Trait diesel::r2d2::CustomizeConnection
source · pub trait CustomizeConnection<C, E>: Debug + Send + Sync + 'static {
// Provided methods
fn on_acquire(&self, conn: &mut C) -> Result<(), E> { ... }
fn on_release(&self, conn: C) { ... }
}
Available on crate feature
r2d2
only.Expand description
A trait which allows for customization of connections.
Provided Methods§
sourcefn on_acquire(&self, conn: &mut C) -> Result<(), E>
fn on_acquire(&self, conn: &mut C) -> Result<(), E>
Called with connections immediately after they are returned from
ManageConnection::connect
.
The default implementation simply returns Ok(())
.
§Errors
If this method returns an error, the connection will be discarded.
sourcefn on_release(&self, conn: C)
fn on_release(&self, conn: C)
Called with connections when they are removed from the pool.
The connections may be broken (as reported by is_valid
or
has_broken
), or have simply timed out.
The default implementation does nothing.