[−][src]Crate mpool
A generic connection pool.
Implementors of the ManageConnection
trait provide the specific
logic to create and check the health of connections.
Example
ⓘThis example is not tested
use std::io; use std::net::SocketAddr; use async_trait::async_trait; use mpool::{ManageConnection, Pool}; use tokio::net::TcpStream; struct MyPool { addr: SocketAddr, } #[async_trait] impl ManageConnection for MyPool { type Connection = TcpStream; async fn connect(&self) -> io::Result<Self::Connection> { TcpStream::connect(self.addr).await } async fn check(&self, _conn: &mut Self::Connection) -> io::Result<()> { Ok(()) } async fn is_valid(&self, _conn: &mut Self::Connection) -> bool { false } }
Structs
Builder | A builder for a connection pool. |
Connection | |
Pool |
Traits
ManageConnection | A trait which provides connection-specific functionality. |