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§
Required Methods§
Sourcefn write(&mut self, frame: &[u8]) -> Result<(), Self::Error>
fn write(&mut self, frame: &[u8]) -> Result<(), Self::Error>
Write all bytes in frame to the transport.
Sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
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.