pub struct WireWriter<'a, const E: bool = true> { /* private fields */ }
Implementations§
Source§impl<'a, const E: bool> WireWriter<'a, E>
impl<'a, const E: bool> WireWriter<'a, E>
Sourcepub fn new(bytes: &'a mut [u8]) -> Self
pub fn new(bytes: &'a mut [u8]) -> Self
Create a WireWriter
that can write data types sequentially to the bytes
slice.
Sourcepub fn advance(&mut self, amount: usize) -> Result<(), WireError>
pub fn advance(&mut self, amount: usize) -> Result<(), WireError>
Advance the writer’s index forward by the given amount of bytes, returning an error if there are insufficient bytes on the wire to do so.
Sourcepub fn advance_up_to(&mut self, amount: usize)
pub fn advance_up_to(&mut self, amount: usize)
Advance the writer’s index forward by the given number of bytes, or to the end of the wire if the amount exceeds the number of remaining bytes.
Sourcepub fn finalize(&self) -> Result<(), WireError>
pub fn finalize(&self) -> Result<(), WireError>
Check if the writer has no more bytes left on the wire that can be written to. If any
bytes remain, return WireError::ExtraBytes
; otherwise, return Ok().
Sourcepub fn finalize_after<T>(
action: Result<(), WireError>,
reader: &Self,
) -> Result<(), WireError>
pub fn finalize_after<T>( action: Result<(), WireError>, reader: &Self, ) -> Result<(), WireError>
Check if the writer has no more bytes left on the wire that can be written to after
the given action. If any bytes remain, return WireError::ExtraBytes
; otherwise,
return Ok().
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check whether the writer has any remaining bytes that can be written to.
Sourcepub fn write<T>(&mut self, writable: &T) -> Result<(), WireError>
pub fn write<T>(&mut self, writable: &T) -> Result<(), WireError>
Write the given data type writable
to the wire.
Sourcepub fn write_part<T, const L: usize>(
&mut self,
writable: &T,
) -> Result<(), WireError>where
T: WireWritePart,
pub fn write_part<T, const L: usize>(
&mut self,
writable: &T,
) -> Result<(), WireError>where
T: WireWritePart,
Write the given data type writable
to L
bytes on the wire.