pub trait Transport:
Send
+ Sync
+ Debug {
// Required methods
fn read(&self, buf: &mut [u8], timeout: Option<Duration>) -> Result<usize>;
fn write(&self, buf: &[u8]) -> Result<usize>;
fn close_write(&self) -> Result<()>;
fn shutdown(&self);
fn kind(&self) -> &'static str;
// Provided method
fn flush(&self) -> Result<()> { ... }
}Expand description
One side of a duplex byte channel.
Reading and writing may happen on two threads at once, and
shutdown may come from a third one.
Required Methods§
Sourcefn read(&self, buf: &mut [u8], timeout: Option<Duration>) -> Result<usize>
fn read(&self, buf: &mut [u8], timeout: Option<Duration>) -> Result<usize>
Reads at least one byte, waiting up to timeout (None: forever).
Ok(0) is the end of the incoming direction; a timeout is
io::ErrorKind::TimedOut.
Sourcefn close_write(&self) -> Result<()>
fn close_write(&self) -> Result<()>
Ends the outgoing direction; the peer reads the end of the stream.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".