pub struct FnFactory<T> { /* private fields */ }Expand description
A ConnectionFactory built from plain closures. Unset hooks fall back to the trait
defaults.
Implementations§
Source§impl<T> FnFactory<T>
impl<T> FnFactory<T>
Sourcepub fn with_validate<F>(self, f: F) -> Self
pub fn with_validate<F>(self, f: F) -> Self
Sets the liveness check.
Sourcepub fn with_reset<F>(self, f: F) -> Self
pub fn with_reset<F>(self, f: F) -> Self
Sets the release-time reset.
Sourcepub fn with_close<F>(self, f: F) -> Self
pub fn with_close<F>(self, f: F) -> Self
Sets the disposal hook.
Trait Implementations§
Source§impl<T> ConnectionFactory<T> for FnFactory<T>
impl<T> ConnectionFactory<T> for FnFactory<T>
Source§fn create(&self) -> Result<T, FactoryError>
fn create(&self) -> Result<T, FactoryError>
Opens a new connection. Should enforce its own connect timeout.
Source§fn validate(&self, conn: &T) -> bool
fn validate(&self, conn: &T) -> bool
A cheap liveness check (e.g.
SELECT 1). false = dead. Defaults to true.Source§fn reset(&self, conn: &T) -> Result<(), FactoryError>
fn reset(&self, conn: &T) -> Result<(), FactoryError>
Called on release to scrub session state (e.g. rollback). Defaults to a no-op.
Source§fn close(&self, conn: &T) -> Result<(), FactoryError>
fn close(&self, conn: &T) -> Result<(), FactoryError>
Disposes of a connection. Defaults to a no-op — most Rust connections close on
Drop;
override only when explicit teardown is needed.Source§fn is_fatal_error(&self, err: &(dyn Error + 'static)) -> bool
fn is_fatal_error(&self, err: &(dyn Error + 'static)) -> bool
Whether
err (raised by user code using the connection) proves the connection is
broken, so it is discarded without further checks. Defaults to false.Auto Trait Implementations§
impl<T> !RefUnwindSafe for FnFactory<T>
impl<T> !UnwindSafe for FnFactory<T>
impl<T> Freeze for FnFactory<T>
impl<T> Send for FnFactory<T>
impl<T> Sync for FnFactory<T>
impl<T> Unpin for FnFactory<T>
impl<T> UnsafeUnpin for FnFactory<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more