[][src]Trait stubborn_io::tokio::UnderlyingIo

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

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

Required methods

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.

Loading content...

Provided methods

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.

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.

Loading content...

Implementations on Foreign Types

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

Loading content...

Implementors

Loading content...