Trait stubborn_io::tokio::UnderlyingIo

source ·
pub trait UnderlyingIo<C>: Sized + Unpin
where C: Clone + Send + Unpin,
{ // Required method fn establish( ctor_arg: C ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send>>; // Provided methods fn is_disconnect_error(&self, err: &Error) -> bool { ... } fn is_final_read(&self, bytes_read: usize) -> bool { ... } }
Expand description

Trait that should be implemented for an AsyncRead and/or AsyncWrite item to enable it to work with the StubbornIo struct.

Required Methods§

source

fn establish(ctor_arg: C) -> Pin<Box<dyn Future<Output = Result<Self>> + Send>>

The creation function is used by StubbornIo in order to establish both the initial IO connection in addition to performing reconnects.

Provided Methods§

source

fn is_disconnect_error(&self, err: &Error) -> bool

When IO items experience an io::Error during operation, it does not necessarily mean it is a disconnect/termination (ex: WouldBlock). This trait provides sensible defaults to classify which errors are considered “disconnects”, but this can be overridden based on the user’s needs.

source

fn is_final_read(&self, bytes_read: usize) -> bool

If the underlying IO item implements AsyncRead, this method allows the user to specify if a technically successful read actually means that the connect is closed. For example, tokio’s TcpStream successfully performs a read of 0 bytes when closed.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<A> UnderlyingIo<A> for TcpStream
where A: ToSocketAddrs + Sync + Send + Clone + Unpin + 'static,

source§

fn establish(addr: A) -> Pin<Box<dyn Future<Output = Result<Self>> + Send>>

Implementors§