pub struct AsyncFnFactory<T> { /* private fields */ }Expand description
An AsyncConnectionFactory built from closures returning [BoxFuture]s.
Implementations§
Source§impl<T> AsyncFnFactory<T>
impl<T> AsyncFnFactory<T>
Sourcepub fn new<F>(create: F) -> Self
pub fn new<F>(create: F) -> Self
Builds a factory from a create closure returning a boxed future.
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> AsyncConnectionFactory<T> for AsyncFnFactory<T>
impl<T> AsyncConnectionFactory<T> for AsyncFnFactory<T>
Source§fn create(&self) -> impl Future<Output = Result<T, FactoryError>> + Send
fn create(&self) -> impl Future<Output = Result<T, FactoryError>> + Send
Opens a new connection.
Source§async fn reset(&self, conn: &T) -> Result<(), FactoryError>
async fn reset(&self, conn: &T) -> Result<(), FactoryError>
Scrubs session state on release. Defaults to a no-op.
Source§async fn close(&self, conn: &T) -> Result<(), FactoryError>
async fn close(&self, conn: &T) -> Result<(), FactoryError>
Disposes of a connection. Defaults to a no-op.
Source§fn 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.Auto Trait Implementations§
impl<T> !RefUnwindSafe for AsyncFnFactory<T>
impl<T> !UnwindSafe for AsyncFnFactory<T>
impl<T> Freeze for AsyncFnFactory<T>where
Box<dyn Fn() -> Pin<Box<dyn Future<Output = Result<T, Box<dyn Error + Sync + Send>>> + Send>> + Sync + Send>: Freeze,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>> + Sync + Send>>: Freeze,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: Freeze,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: Freeze,
impl<T> Send for AsyncFnFactory<T>where
Box<dyn Fn() -> Pin<Box<dyn Future<Output = Result<T, Box<dyn Error + Sync + Send>>> + Send>> + Sync + Send>: Send,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>> + Sync + Send>>: Send,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: Send,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: Send,
impl<T> Sync for AsyncFnFactory<T>where
Box<dyn Fn() -> Pin<Box<dyn Future<Output = Result<T, Box<dyn Error + Sync + Send>>> + Send>> + Sync + Send>: Sync,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>> + Sync + Send>>: Sync,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: Sync,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: Sync,
impl<T> Unpin for AsyncFnFactory<T>where
Box<dyn Fn() -> Pin<Box<dyn Future<Output = Result<T, Box<dyn Error + Sync + Send>>> + Send>> + Sync + Send>: Unpin,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>> + Sync + Send>>: Unpin,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: Unpin,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: Unpin,
impl<T> UnsafeUnpin for AsyncFnFactory<T>where
Box<dyn Fn() -> Pin<Box<dyn Future<Output = Result<T, Box<dyn Error + Sync + Send>>> + Send>> + Sync + Send>: UnsafeUnpin,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>> + Sync + Send>>: UnsafeUnpin,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: UnsafeUnpin,
Option<Box<dyn for<'a> Fn(&'a T) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>> + Sync + Send>>: UnsafeUnpin,
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