pub struct BinaryDecoder<R: Read> { /* private fields */ }Expand description
Binary decoder with versioning support
Implementations§
Source§impl<R: Read> BinaryDecoder<R>
impl<R: Read> BinaryDecoder<R>
Sourcepub fn read_header(&mut self) -> ChieResult<u8>
pub fn read_header(&mut self) -> ChieResult<u8>
Read and verify the message header (magic bytes + version)
§Errors
Returns error if header is invalid or unsupported
Sourcepub fn read_u8(&mut self) -> ChieResult<u8>
pub fn read_u8(&mut self) -> ChieResult<u8>
Sourcepub fn read_u32(&mut self) -> ChieResult<u32>
pub fn read_u32(&mut self) -> ChieResult<u32>
Sourcepub fn read_u64(&mut self) -> ChieResult<u64>
pub fn read_u64(&mut self) -> ChieResult<u64>
Sourcepub fn read_bytes(&mut self) -> ChieResult<Vec<u8>>
pub fn read_bytes(&mut self) -> ChieResult<Vec<u8>>
Read a variable-length byte array (length prefix + data)
§Errors
Returns error if reading fails or length is invalid
Sourcepub fn read_string(&mut self) -> ChieResult<String>
pub fn read_string(&mut self) -> ChieResult<String>
Read a string (UTF-8 encoded with length prefix)
§Errors
Returns error if reading fails or string is invalid UTF-8
Sourcepub fn read_bool(&mut self) -> ChieResult<bool>
pub fn read_bool(&mut self) -> ChieResult<bool>
Sourcepub fn verify_checksum(&mut self, data: &[u8]) -> ChieResult<()>
pub fn verify_checksum(&mut self, data: &[u8]) -> ChieResult<()>
Read and verify CRC32 checksum for the given data
§Errors
Returns error if checksum doesn’t match or reading fails
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consume the decoder and return the underlying reader
Sourcepub fn read_bytes_chunked<F>(
&mut self,
chunk_size: usize,
callback: F,
) -> ChieResult<u64>
pub fn read_bytes_chunked<F>( &mut self, chunk_size: usize, callback: F, ) -> ChieResult<u64>
Read large byte array in chunks with a callback to process each chunk
§Errors
Returns error if reading fails or callback returns error
Sourcepub fn copy_to_writer<W: Write>(
&mut self,
writer: &mut W,
size: u64,
) -> ChieResult<u64>
pub fn copy_to_writer<W: Write>( &mut self, writer: &mut W, size: u64, ) -> ChieResult<u64>
Stream data directly to a writer without buffering entire payload
§Errors
Returns error if copying fails
Auto Trait Implementations§
impl<R> Freeze for BinaryDecoder<R>where
R: Freeze,
impl<R> RefUnwindSafe for BinaryDecoder<R>where
R: RefUnwindSafe,
impl<R> Send for BinaryDecoder<R>where
R: Send,
impl<R> Sync for BinaryDecoder<R>where
R: Sync,
impl<R> Unpin for BinaryDecoder<R>where
R: Unpin,
impl<R> UnwindSafe for BinaryDecoder<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more