Struct Deserializer

Source
pub struct Deserializer<'data> { /* private fields */ }
Expand description

Deserializer referring an existing u8 buffer

Implementations§

Source§

impl<'data> Deserializer<'data>

Source

pub fn new(data: &'data [u8]) -> Deserializer<'data>

Create a new Deserializer referring the supplied u8 buffer

Source

pub fn cursor(&self) -> usize

Get current byte position of the reader

Source

pub fn remaining(&self) -> usize

Get amount of bytes remaining for consumption

Source

pub fn try_offset(&mut self, offset: usize) -> Result<()>

Advance the reader by offset bytes

Source

pub fn try_align_u32(&mut self) -> Result<()>

Advance the cursor to ensure that current cursor position is 32-bit aligned

Source

pub fn try_align_u64(&mut self) -> Result<()>

Advance the cursor to ensure that current cursor position is 64-bit aligned

Source

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)?;
Source

pub fn try_set_cursor(&mut self, cursor: usize) -> Result<()>

Set the cursor byte position to the given cursor value

Source

pub fn try_load_u8_vec(&mut self, len: usize) -> Result<Vec<u8>>

Try reading Vec<u8> buffer of the supplied len byte length.

Source

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.

Source

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.

Source

pub fn load_u8(&mut self) -> u8

Load a u8 value

Source

pub fn try_load_u8(&mut self) -> Result<u8>

Try load a u8 value

Source

pub fn load_u16le(&mut self) -> u16

Load a u16 little-endian value

Source

pub fn try_load_u16le(&mut self) -> Result<u16>

Try load a u16 little-endian value

Source

pub fn load_u32le(&mut self) -> u32

Load a u32 little-endian value

Source

pub fn try_load_u32le(&mut self) -> Result<u32>

Try load a u32 little-endian value

Source

pub fn load_u64le(&mut self) -> u64

Load a u64 little-endian value

Source

pub fn try_load_u64le(&mut self) -> Result<u64>

Try load a u64 little-endian value

Source

pub fn load<S: Deserialize>(&mut self) -> S

Load a primitive implementing a Deserialize trait

Source

pub fn try_load<S: TryDeserialize>(&mut self) -> Result<S, S::Error>

Try load a primitive implementing a Deserialize trait

Auto Trait Implementations§

§

impl<'data> Freeze for Deserializer<'data>

§

impl<'data> RefUnwindSafe for Deserializer<'data>

§

impl<'data> Send for Deserializer<'data>

§

impl<'data> Sync for Deserializer<'data>

§

impl<'data> Unpin for Deserializer<'data>

§

impl<'data> UnwindSafe for Deserializer<'data>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.