Struct wire_rs::WireWriter
source · 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>where
T: WireWrite + ?Sized,
pub fn write<T>(&mut self, writable: &T) -> Result<(), WireError>where
T: WireWrite + ?Sized,
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.