Skip to main content

Transport

Trait Transport 

Source
pub trait Transport {
    // Required methods
    fn write_all(&mut self, bytes: &[u8]) -> Result<(), Error>;
    fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>;

    // Provided method
    fn flush(&mut self) -> Result<(), Error> { ... }
}
Expand description

Synchronous half-duplex byte transport.

Required Methods§

Source

fn write_all(&mut self, bytes: &[u8]) -> Result<(), Error>

Send bytes in their entirety. The implementation must not return until either every byte is on the wire or an error has occurred.

Source

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

Read up to buf.len() bytes.

Implementations should return Ok(0) when no bytes are available before the deadline configured at the transport level. Drivers track REPLY_DELAY independently via the crate::clock::Clock.

Provided Methods§

Source

fn flush(&mut self) -> Result<(), Error>

Flush any internally-buffered bytes.

Implementations on Foreign Types§

Source§

impl<T: Transport + ?Sized> Transport for &mut T

Source§

fn write_all(&mut self, bytes: &[u8]) -> Result<(), Error>

Source§

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

Source§

fn flush(&mut self) -> Result<(), Error>

Implementors§

Source§

impl Transport for VecTransport

Available on crate feature alloc only.