2 unstable releases
0.2.0 | Jul 12, 2024 |
---|---|
0.1.0 | Jul 12, 2024 |
6KB
81 lines
use embedded_io::Write;
use embedded_io_async::Write as Awrite;
use awrite::{awrite, awriteln, AwriteBuf};
let mut async_sink = Vec::<u8>::new();
let mut buf = AwriteBuf::new([0u8; 32], &mut async_sink);
awrite!(buf, "Hello").unwrap();
awriteln!(buf, "{:?} {}", 7, "bar").unwrap();
awriteln!(&mut buf).unwrap();
assert_eq!(awriteln!(buf, "{:032}", 0),
Err(embedded_io::WriteFmtError::Other(
awrite::Error::Sync(embedded_io::SliceWriteError::Full))
));
assert_eq!(core::str::from_utf8(&async_sink).unwrap(), "Hello7 bar\n\n");
let mut async_sink = [0u8; 8];
let mut slic = &mut async_sink[..];
let mut buf = AwriteBuf::new([0u8; 16], &mut slic);
awriteln!(buf, "{:07}", 0).unwrap();
assert_eq!(awriteln!(buf, "{:08}", 0),
Err(embedded_io::WriteFmtError::Other(
awrite::Error::Async(embedded_io::SliceWriteError::Full))
));
Dependencies
~47KB