#[non_exhaustive]pub struct LifecycleHooks<C> {
pub on_create: Option<Box<dyn Fn(&C) + Send + Sync>>,
pub before_acquire: Option<Box<dyn Fn() + Send + Sync>>,
pub on_checkout: Option<Box<dyn Fn(&C) + Send + Sync>>,
pub on_checkin: Option<Box<dyn Fn(&C) + Send + Sync>>,
pub after_release: Option<Box<dyn Fn() + Send + Sync>>,
pub on_destroy: Option<Box<dyn Fn() + Send + Sync>>,
}Expand description
Lifecycle hook callbacks. All hooks are optional.
Connection-aware hooks (on_create, on_checkout, on_checkin) receive a &C
reference to the connection. Non-connection hooks (before_acquire, after_release,
on_destroy) take no parameters — on_destroy because the connection may be invalid,
and before_acquire/after_release because no specific connection is involved yet.
Marked #[non_exhaustive] so additional hooks can be introduced in future
minor releases without breaking downstream construction.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.on_create: Option<Box<dyn Fn(&C) + Send + Sync>>Called after a new connection is created.
before_acquire: Option<Box<dyn Fn() + Send + Sync>>Called before attempting to acquire a connection (checkout starts).
on_checkout: Option<Box<dyn Fn(&C) + Send + Sync>>Called when a connection is checked out and ready to use.
on_checkin: Option<Box<dyn Fn(&C) + Send + Sync>>Called when a connection passes health checks and is about to return to the pool.
after_release: Option<Box<dyn Fn() + Send + Sync>>Called after a connection is fully released (all exit paths from return).
on_destroy: Option<Box<dyn Fn() + Send + Sync>>Called when a connection is destroyed (expired, invalid, or during drain).