pub trait IoWrite {
// Required method
fn write(&mut self, buf: &[u8]) -> usize;
// Provided method
fn write_ring_buffer(&mut self, buf: &RingBuffer<'_, u8>) -> usize { ... }
}
Expand description
Implementation of std::io::Write
for no_std
.
This takes bytes instead of a string (contrary to core::fmt::Write
), but
we cannot use std::io::Write' as it isn't available in
no_std(due to
std::io::Error` not being available).
Also, in our use cases, writes are infallible, so the write function cannot
return an Err
, however it might not be able to write everything, so it
returns the number of bytes written.
See also the tracking issue: https://github.com/rust-lang/rfcs/issues/2262.