pub struct Writer<W: Write> { /* private fields */ }Expand description
The writer type used in [storekey::Encode].
Handles writing into the encoding buffer and escaping bytes if needed.
Will only escape bytes where they might conflict with a terminal zero byte.
To do have this function correctly you need to call Writer::mark_terminator function where
appropriate.
Implementations§
Source§impl<W: Write> Writer<W>
impl<W: Write> Writer<W>
pub const fn new(w: W) -> Self
Sourcepub fn mark_terminator(&mut self)
pub fn mark_terminator(&mut self)
Marks a position where a null byte is used as a terminator.
Should be called if when decoding a zero byte as the next character would result in the serialize ending prematurely.
Sourcepub fn write_escaped_slice(
&mut self,
slice: &EscapedSlice,
) -> Result<(), EncodeError>
pub fn write_escaped_slice( &mut self, slice: &EscapedSlice, ) -> Result<(), EncodeError>
Write an already escaped slice.
Sourcepub fn write_slice(&mut self, slice: &[u8]) -> Result<(), EncodeError>
pub fn write_slice(&mut self, slice: &[u8]) -> Result<(), EncodeError>
Writes an runtime sized slice, escaping null bytes and ending the slice with a terminal zero byte.
Sourcepub fn write_array<const LEN: usize>(
&mut self,
array: [u8; LEN],
) -> Result<(), EncodeError>
pub fn write_array<const LEN: usize>( &mut self, array: [u8; LEN], ) -> Result<(), EncodeError>
Write a fixed size array into the buffer.
As it is fixed size it will not write a terminal zero byte after the end.
This function will escape the first byte of the array if needed.
All other write_* functions which write fixed sized types call this function.