Trait SimpleDataDeserializer

Source
pub trait SimpleDataDeserializer {
Show 13 methods // Required methods fn data(&self) -> &[u8] ; fn read(&mut self, size: usize) -> Result<()>; // Provided methods fn read_u8(&mut self) -> Result<u8> { ... } fn read_i8(&mut self) -> Result<i8> { ... } fn read_u16(&mut self) -> Result<u16> { ... } fn read_u32(&mut self) -> Result<u32> { ... } fn read_u64(&mut self) -> Result<u64> { ... } fn read_i16(&mut self) -> Result<i16> { ... } fn read_i32(&mut self) -> Result<i32> { ... } fn read_i64(&mut self) -> Result<i64> { ... } fn read_f32(&mut self) -> Result<f32> { ... } fn read_f64(&mut self) -> Result<f64> { ... } fn read_byte_array(&mut self) -> Result<()> { ... }
}
Expand description

This trait implements a simple deserializer for basic data types. It follows the format used by Java’s java.io.DataOutputStream so it reads the values using the big endian format.

This trait also allows the definition of a custom Result type thar will allow its methods to be used with the operatior ?.

Required Methods§

Source

fn data(&self) -> &[u8]

The slice with the last data read.

Source

fn read(&mut self, size: usize) -> Result<()>

Reads the specified umber of bytes. The data read will available by Self::data().

Arguments:

  • size: Number of bytes to read;

Provided Methods§

Source

fn read_u8(&mut self) -> Result<u8>

Reads an u8 value.

Source

fn read_i8(&mut self) -> Result<i8>

Reads an i8 value.

Source

fn read_u16(&mut self) -> Result<u16>

Reads an u16 value.

Source

fn read_u32(&mut self) -> Result<u32>

Reads an u32 value.

Source

fn read_u64(&mut self) -> Result<u64>

Reads an u16 value.

Source

fn read_i16(&mut self) -> Result<i16>

Reads an i16 value.

Source

fn read_i32(&mut self) -> Result<i32>

Reads an i32 value.

Source

fn read_i64(&mut self) -> Result<i64>

Reads an i64 value.

Source

fn read_f32(&mut self) -> Result<f32>

Reads an f32 value.

Source

fn read_f64(&mut self) -> Result<f64>

Reads an f64 value.

Source

fn read_byte_array(&mut self) -> Result<()>

Writes a byte array. The size of the byte array is encoded as an u16 value followed by the bytes of the array.

Arguments:

  • v: The value to write;

Implementors§