pub struct Deserializer<'data> { /* private fields */ }
Expand description
Deserializer referring an existing u8
buffer
Implementations§
Source§impl<'data> Deserializer<'data>
impl<'data> Deserializer<'data>
Sourcepub fn new(data: &'data [u8]) -> Deserializer<'data>
pub fn new(data: &'data [u8]) -> Deserializer<'data>
Create a new Deserializer
referring the supplied u8
buffer
Sourcepub fn try_offset(&mut self, offset: usize) -> Result<()>
pub fn try_offset(&mut self, offset: usize) -> Result<()>
Advance the reader by offset
bytes
Sourcepub fn try_align_u32(&mut self) -> Result<()>
pub fn try_align_u32(&mut self) -> Result<()>
Advance the cursor to ensure that current cursor position is 32-bit aligned
Sourcepub fn try_align_u64(&mut self) -> Result<()>
pub fn try_align_u64(&mut self) -> Result<()>
Advance the cursor to ensure that current cursor position is 64-bit aligned
Sourcepub fn try_align(&mut self, align: usize) -> Result<()>
pub fn try_align(&mut self, align: usize) -> Result<()>
Advance the cursor to ensure its alignment is on the align
byte boundary.
The following ensures that the cursor is on a 128-bit alignment:
deser.try_align(16)?;
Sourcepub fn try_set_cursor(&mut self, cursor: usize) -> Result<()>
pub fn try_set_cursor(&mut self, cursor: usize) -> Result<()>
Set the cursor byte position to the given cursor
value
Sourcepub fn try_load_u8_vec(&mut self, len: usize) -> Result<Vec<u8>>
pub fn try_load_u8_vec(&mut self, len: usize) -> Result<Vec<u8>>
Try reading Vec<u8>
buffer of the supplied len
byte length.
Sourcepub fn try_load_u16le_vec(&mut self, len: usize) -> Result<Vec<u16>>
pub fn try_load_u16le_vec(&mut self, len: usize) -> Result<Vec<u16>>
Try reading Vec<u16>
array of the supplied len
elements.
The u16
values are read as little-endian values.
Sourcepub fn try_load_utf16le_sz(&mut self) -> Result<String>
pub fn try_load_utf16le_sz(&mut self) -> Result<String>
Try reading an array of u16
little-endian values from a
zero-terminated u16
array and return it as a Rust String
.
This function is useful for reading windows PCWSTR
zero-terminated
strings into Rust strings.
Sourcepub fn try_load_u8(&mut self) -> Result<u8>
pub fn try_load_u8(&mut self) -> Result<u8>
Try load a u8 value
Sourcepub fn load_u16le(&mut self) -> u16
pub fn load_u16le(&mut self) -> u16
Load a u16 little-endian value
Sourcepub fn try_load_u16le(&mut self) -> Result<u16>
pub fn try_load_u16le(&mut self) -> Result<u16>
Try load a u16 little-endian value
Sourcepub fn load_u32le(&mut self) -> u32
pub fn load_u32le(&mut self) -> u32
Load a u32 little-endian value
Sourcepub fn try_load_u32le(&mut self) -> Result<u32>
pub fn try_load_u32le(&mut self) -> Result<u32>
Try load a u32 little-endian value
Sourcepub fn load_u64le(&mut self) -> u64
pub fn load_u64le(&mut self) -> u64
Load a u64 little-endian value
Sourcepub fn try_load_u64le(&mut self) -> Result<u64>
pub fn try_load_u64le(&mut self) -> Result<u64>
Try load a u64 little-endian value
Sourcepub fn load<S: Deserialize>(&mut self) -> S
pub fn load<S: Deserialize>(&mut self) -> S
Load a primitive implementing a Deserialize
trait
Sourcepub fn try_load<S: TryDeserialize>(&mut self) -> Result<S, S::Error>
pub fn try_load<S: TryDeserialize>(&mut self) -> Result<S, S::Error>
Try load a primitive implementing a Deserialize
trait