pub struct FrameWriter<'a> { /* private fields */ }Expand description
Incremental frame builder over a caller-provided buffer.
Implementations§
Source§impl<'a> FrameWriter<'a>
impl<'a> FrameWriter<'a>
Sourcepub fn new(buf: &'a mut [u8], tid: u8, cmd: Cmd) -> Result<Self, WriteError>
pub fn new(buf: &'a mut [u8], tid: u8, cmd: Cmd) -> Result<Self, WriteError>
Start a frame with the given TID and command.
pub fn write_u8(&mut self, byte: u8) -> Result<(), WriteError>
pub fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), WriteError>
pub fn write_pui(&mut self, value: u32) -> Result<(), WriteError>
pub fn write_u16_le(&mut self, value: u16) -> Result<(), WriteError>
pub fn write_u32_le(&mut self, value: u32) -> Result<(), WriteError>
pub const fn is_empty(&self) -> bool
Sourcepub fn write_entry(&mut self, key: u32, value: &[u8]) -> Result<(), WriteError>
pub fn write_entry(&mut self, key: u32, value: &[u8]) -> Result<(), WriteError>
Append one multi-property entry: the combined length of the key and value, then the key, then the value.
The entry is written whole or not at all, so a caller that runs out of room keeps a well-formed frame of the entries that fit.
Sourcepub fn write_status_entry(&mut self, status: Status) -> Result<(), WriteError>
pub fn write_status_entry(&mut self, status: Status) -> Result<(), WriteError>
Append an entry reporting a status in the position of the property it answers.