pub trait BufferedSerial: Sync {
// Required methods
fn read(&self, buf: &mut [u8]) -> impl Future<Output = usize>;
fn write(&self, buf: &[u8]) -> impl Future<Output = ()>;
fn check_dropped_bytes(&self) -> usize;
}Expand description
Platform-agnostic buffered serial bridge.
The serial bridge is the inner loop that pumps bytes between the SSH
channel and the target UART. Every platform provides a concrete type
implementing this trait (ESP32: ssh_stamp_esp32::BufferedUart).
read/write take &self (not &mut self) because the bridge splits
each direction into its own future and runs them concurrently via
embassy_futures::select::select. Implementations back this with
internal pipes / interrupt-filled buffers.
Required Methods§
Sourcefn read(&self, buf: &mut [u8]) -> impl Future<Output = usize>
fn read(&self, buf: &mut [u8]) -> impl Future<Output = usize>
Read as many bytes as are available, up to buf.len(). Returns the
number of bytes read. Awaits until at least one byte is available.
Sourcefn write(&self, buf: &[u8]) -> impl Future<Output = ()>
fn write(&self, buf: &[u8]) -> impl Future<Output = ()>
Queue bytes to be written. Completes once buf has been accepted
by the internal buffer (may still be in flight on the wire).
Sourcefn check_dropped_bytes(&self) -> usize
fn check_dropped_bytes(&self) -> usize
Return how many received bytes were dropped since the last call due to the internal buffer being full. Resets the counter.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".