[−][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(()) } }
Structs
Builder | A builder for a connection pool. |
Connection | A smart pointer wrapping a connection. |
Pool | A generic connection pool. |
Traits
ManageConnection | A trait which provides connection-specific functionality. |