Skip to main content

Transport

Trait Transport 

Source
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§

Source

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.

Source

fn write(&self, buf: &[u8]) -> Result<usize>

Writes at least one byte of buf.

Source

fn close_write(&self) -> Result<()>

Ends the outgoing direction; the peer reads the end of the stream.

Source

fn shutdown(&self)

Hangs up both directions; pending and later operations end.

Source

fn kind(&self) -> &'static str

The endpoint kind, such as shm.

Provided Methods§

Source

fn flush(&self) -> Result<()>

Pushes buffered bytes to the peer.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§