Skip to main content

Transport

Trait Transport 

Source
pub trait Transport {
    // Required methods
    fn read(&mut self, buf: &mut [u8]) -> usize;
    fn write(&mut self, buf: &[u8]) -> usize;
}
Expand description

Non-blocking byte-stream transport.

Both methods are non-blocking and return the number of bytes transferred. Returning 0 means no bytes were available (read) or the sink was full (write). Callers must poll in a loop rather than block.

Required Methods§

Source

fn read(&mut self, buf: &mut [u8]) -> usize

Read up to buf.len() bytes. Returns the number of bytes read. Returns 0 if no data is currently available.

Source

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

Write up to buf.len() bytes. Returns the number of bytes written. May return less than buf.len() if the sink buffer is full.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§