pub trait PeripheralHandle: Send {
// Required methods
fn read(&mut self, buffer: &mut [u8]) -> Result<usize>;
fn write(&mut self, buffer: &[u8]) -> Result<usize>;
// Provided methods
fn flush(&mut self) -> Result<()> { ... }
fn control(
&mut self,
_command: ControlCommandIdentifier,
_input: &AnyByLayout,
_output: &mut AnyByLayout,
) -> Result<()> { ... }
}Expand description
Class-specific handle wrapped by PeripheralDevice.
Every method is a single synchronous attempt. It must return promptly
without waiting for hardware, because it runs on the executor. A peripheral
that would have to wait returns IoErrorKind::WouldBlock (for example when a
UART reports WouldBlock), and the caller decides whether to retry. Callers
do not retain buffers past the call.
control forwards command identifiers that the class defined itself. The
base never interprets them.