pub trait Manager:
Sized
+ Send
+ Sync
+ 'static {
type Connection: Unpin + 'static;
type Error: Debug + From<Self::TimeoutError> + 'static;
type Timeout: Future<Output = Self::TimeoutError> + Send;
type TimeoutError: Send + Debug + 'static;
// Required methods
fn connect(
&self,
) -> ManagerFuture<'_, Result<Self::Connection, Self::Error>>;
fn is_valid<'a>(
&'a self,
conn: &'a mut Self::Connection,
) -> ManagerFuture<'a, Result<(), Self::Error>>;
fn is_closed(&self, conn: &mut Self::Connection) -> bool;
fn spawn<Fut>(&self, fut: Fut)
where Fut: Future<Output = ()> + Send + 'static;
fn timeout<Fut: Future>(
&self,
fut: Fut,
_dur: Duration,
) -> ManagerTimeout<Fut, Self::Timeout> ⓘ;
// Provided methods
fn on_start(&self, _shared_pool: &SharedManagedPool<Self>) { ... }
fn on_stop(&self) { ... }
}
Expand description
§Types for different runtimes:
Trait type runtime Type constructor Manager::Timeout tokio tokio::time::Delay tokio::time::delay_for async-std smol::Timer smol::Timer::after
Manager::TimeoutError tokio () async-std std::time::Instant
Required Associated Types§
type Connection: Unpin + 'static
type Error: Debug + From<Self::TimeoutError> + 'static
type Timeout: Future<Output = Self::TimeoutError> + Send
type TimeoutError: Send + Debug + 'static
Required Methods§
Sourcefn connect(&self) -> ManagerFuture<'_, Result<Self::Connection, Self::Error>>
fn connect(&self) -> ManagerFuture<'_, Result<Self::Connection, Self::Error>>
generate a new connection and put it into pool.
Sourcefn is_valid<'a>(
&'a self,
conn: &'a mut Self::Connection,
) -> ManagerFuture<'a, Result<(), Self::Error>>
fn is_valid<'a>( &'a self, conn: &'a mut Self::Connection, ) -> ManagerFuture<'a, Result<(), Self::Error>>
check if a connection is valid.
*. Only called when Builder.always_check == true
Sourcefn is_closed(&self, conn: &mut Self::Connection) -> bool
fn is_closed(&self, conn: &mut Self::Connection) -> bool
check if a connection is closed.
This happens before a connection put back to pool.
Provided Methods§
Sourcefn on_start(&self, _shared_pool: &SharedManagedPool<Self>)
fn on_start(&self, _shared_pool: &SharedManagedPool<Self>)
This method will be called when Pool<Manager>::init()
executes.
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.