pub trait ByteStream {
// Required methods
async fn read(&mut self, buf: &mut [u8], timeout: Duration) -> Result<usize>;
async fn write(&mut self, data: &[u8]) -> Result<()>;
async fn purge(&mut self) -> Result<()>;
}Expand description
A byte stream: serial ports, USB-serial chips, Bluetooth classic RFCOMM, or a BLE GATT link that behaves like a serial line.
Required Methods§
Sourceasync fn read(&mut self, buf: &mut [u8], timeout: Duration) -> Result<usize>
async fn read(&mut self, buf: &mut [u8], timeout: Duration) -> Result<usize>
Reads at least one byte into buf and returns how many bytes were read.
§Errors
Error::Timeout if no byte arrives within timeout, or
a transport error.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".