Skip to main content

ManageConnection

Trait ManageConnection 

Source
pub trait ManageConnection:
    Send
    + Sync
    + 'static {
    type Connection: 'static;
    type Error: Error + 'static;

    // Required methods
    fn connect(
        &self,
    ) -> impl Future<Output = Result<Self::Connection, Self::Error>>;
    fn is_valid(
        &self,
        conn: &mut Self::Connection,
    ) -> impl Future<Output = Result<(), Self::Error>>;
    fn has_broken(&self, conn: &mut Self::Connection) -> bool;
}
Expand description

Teaches a Pool how to open and check the connections it hands out.

One manager is shared — behind an Arc — by every thread’s LocalPool, so the manager value itself is Send + Sync. The connections it produces are not: each belongs to the io_uring ring of the thread that opened it and must live and die there. That is the one difference from bb8’s ManageConnection — Connection carries no Send bound, and every future returned here runs on a single thread.

Required Associated Types§

Source

type Connection: 'static

The connection this manager opens: a compio TcpStream, a framed client on top of one, a reusable buffer — anything a thread keeps a bounded number of. Ring-bound, hence not Send.

Source

type Error: Error + 'static

What connect and is_valid fail with.

Required Methods§

Source

fn connect(&self) -> impl Future<Output = Result<Self::Connection, Self::Error>>

Open a new connection. Called on the thread whose LocalPool asked for it, inside that thread’s runtime, so its I/O is submitted to that thread’s ring.

Source

fn is_valid( &self, conn: &mut Self::Connection, ) -> impl Future<Output = Result<(), Self::Error>>

Check a connection as it is handed out, when test_on_check_out is set. Returning Err discards the connection; the pool then opens a fresh one in its place.

Source

fn has_broken(&self, conn: &mut Self::Connection) -> bool

A synchronous, infallible liveness check run as a connection is returned. Returning true drops it instead of putting it back on the idle list.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§