Trait il2_utils::simple_serialization::SimpleDataSerializer[][src]

pub trait SimpleDataSerializer {
    fn write(&mut self, v: &[u8]) -> Result<()>;
fn write_u8(&mut self, v: u8) -> Result<()>; fn write_u16(&mut self, v: u16) -> Result<()> { ... }
fn write_u32(&mut self, v: u32) -> Result<()> { ... }
fn write_u64(&mut self, v: u64) -> Result<()> { ... }
fn write_i8(&mut self, v: i8) -> Result<()> { ... }
fn write_i16(&mut self, v: i16) -> Result<()> { ... }
fn write_i32(&mut self, v: i32) -> Result<()> { ... }
fn write_i64(&mut self, v: i64) -> Result<()> { ... }
fn write_f32(&mut self, v: f32) -> Result<()> { ... }
fn write_f64(&mut self, v: f64) -> Result<()> { ... }
fn write_byte_array(&mut self, v: &[u8]) -> Result<()> { ... } }
Expand description

This trait implements a simple serializer for basic data types. It follows the format used by Java’s java.io.DataOutputStream and write all 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

Writes the byte slice.

Arguments:

  • v: The value to write;

Writes an u8 value.

Arguments:

  • v: The value to write;

Provided methods

Writes an u16 value.

Arguments:

  • v: The value to write;

Writes an u32 value.

Arguments:

  • v: The value to write;

Writes an u64 value.

Arguments:

  • v: The value to write;

Writes an i8 value.

Arguments:

  • v: The value to write;

Writes an i16 value.

Arguments:

  • v: The value to write;

Writes an i32 value.

Arguments:

  • v: The value to write;

Writes an i64 value.

Arguments:

  • v: The value to write;

Writes a f32 value.

Arguments:

  • v: The value to write;

Writes a f64 value.

Arguments:

  • v: The value to write;

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;

Implementations on Foreign Types

Implementors