Trait stubborn_io::tokio::UnderlyingIo
source · pub trait UnderlyingIo<C>: Sized + 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§
Provided Methods§
sourcefn is_disconnect_error(&self, err: &Error) -> bool
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.
sourcefn is_final_read(&self, bytes_read: usize) -> bool
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.