Skip to main content

Transport

Trait Transport 

Source
pub trait Transport {
    type Error;

    // Required methods
    fn write(&mut self, frame: &[u8]) -> Result<(), Self::Error>;
    fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>;
}
Expand description

A synchronous byte-oriented I/O channel.

Implementations cover anything from a real serial port to a TCP socket or an in-memory test double.

Required Associated Types§

Source

type Error

The error type produced by transport operations.

Required Methods§

Source

fn write(&mut self, frame: &[u8]) -> Result<(), Self::Error>

Write all bytes in frame to the transport.

Source

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

Read up to buf.len() bytes from the transport into buf.

Returns the number of bytes actually read. A return value of 0 may indicate that the connection was closed or that no data was available at this time, depending on the implementation.

Implementors§

Source§

impl Transport for MockTransport

Available on crate feature std only.