pub struct Decoder<'a> { /* private fields */ }Expand description
A generic decoder that deserializes primitive types and collections from a byte slice.
Implementations§
Source§impl<'a> Decoder<'a>
impl<'a> Decoder<'a>
Sourcepub fn read_u8(&mut self) -> AzUtilResult<u8>
pub fn read_u8(&mut self) -> AzUtilResult<u8>
Reads a single u8 from the buffer.
Sourcepub fn read_usize(&mut self) -> AzUtilResult<usize>
pub fn read_usize(&mut self) -> AzUtilResult<usize>
Reads a usize in big-endian format.
Sourcepub fn read_u16(&mut self) -> AzUtilResult<u16>
pub fn read_u16(&mut self) -> AzUtilResult<u16>
Reads a u16 (2 bytes) in big-endian format.
Sourcepub fn read_vec<T>(&mut self) -> AzUtilResult<Vec<T>>
pub fn read_vec<T>(&mut self) -> AzUtilResult<Vec<T>>
Reads a vector of elements of type T by reading its length and decoding each element.
Sourcepub fn read_opt<T: Codec>(&mut self) -> AzUtilResult<Option<T>>
pub fn read_opt<T: Codec>(&mut self) -> AzUtilResult<Option<T>>
Reads an Option<T> by checking the presence flag and decoding the value if present.
Sourcepub fn read_slice<T: Codec>(&mut self) -> AzUtilResult<Vec<T>>
pub fn read_slice<T: Codec>(&mut self) -> AzUtilResult<Vec<T>>
Reads a slice of elements of type T as a vector.
Sourcepub fn read_u32(&mut self) -> AzUtilResult<u32>
pub fn read_u32(&mut self) -> AzUtilResult<u32>
Reads a u32 (4 bytes) in big-endian format.
Sourcepub fn read_i8(&mut self) -> AzUtilResult<i8>
pub fn read_i8(&mut self) -> AzUtilResult<i8>
Reads an i8 value.
Sourcepub fn read_i64(&mut self) -> AzUtilResult<i64>
pub fn read_i64(&mut self) -> AzUtilResult<i64>
Reads an i64 (8 bytes) in big-endian format.
Sourcepub fn read_u64(&mut self) -> AzUtilResult<u64>
pub fn read_u64(&mut self) -> AzUtilResult<u64>
Reads a u64 (8 bytes) in big-endian format.
Sourcepub fn read_bytes(&mut self, size: u32) -> AzUtilResult<Vec<u8>>
pub fn read_bytes(&mut self, size: u32) -> AzUtilResult<Vec<u8>>
Reads a sequence of bytes of the specified length.
Sourcepub fn read_string(&mut self) -> AzUtilResult<String>
pub fn read_string(&mut self) -> AzUtilResult<String>
Reads a UTF-8 string prefixed with its length.
Sourcepub fn read_bool(&mut self) -> AzUtilResult<bool>
pub fn read_bool(&mut self) -> AzUtilResult<bool>
Reads a boolean value (1 = true, 0 = false).
Auto Trait Implementations§
impl<'a> Freeze for Decoder<'a>
impl<'a> RefUnwindSafe for Decoder<'a>
impl<'a> Send for Decoder<'a>
impl<'a> Sync for Decoder<'a>
impl<'a> Unpin for Decoder<'a>
impl<'a> UnsafeUnpin for Decoder<'a>
impl<'a> UnwindSafe for Decoder<'a>
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