Trait il2_utils::simple_serialization::SimpleDataDeserializer[][src]

pub trait SimpleDataDeserializer {
Show 13 methods fn data(&self) -> &[u8];
fn read(&mut self, size: usize) -> Result<()>; 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

The slice with the last data read.

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

Arguments:

  • size: Number of bytes to read;

Provided methods

Reads an u8 value.

Reads an i8 value.

Reads an u16 value.

Reads an u32 value.

Reads an u16 value.

Reads an i16 value.

Reads an i32 value.

Reads an i64 value.

Reads an f32 value.

Reads an f64 value.

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