BinaryWriter

Struct BinaryWriter 

Source
pub struct BinaryWriter { /* private fields */ }
Expand description

BinaryWriter is used to serialize various data types into a byte buffer.

Implementations§

Source§

impl BinaryWriter

Source

pub fn new() -> Self

Creates a new BinaryWriter with an empty buffer.

Source

pub fn get_data(self) -> Vec<u8>

Returns a reference to the internal byte buffer.

Source

pub fn write_u8(&mut self, value: u8)

Writes a u8 value to the buffer.

Source

pub fn write_u16(&mut self, value: u16)

Writes a u16 value to the buffer in little-endian order.

Source

pub fn write_u32(&mut self, value: u32)

Writes a u32 value to the buffer in little-endian order.

Source

pub fn write_u64(&mut self, value: u64)

Writes a u64 value to the buffer in little-endian order.

Source

pub fn write_i8(&mut self, value: i8)

Writes an i8 value to the buffer.

Source

pub fn write_i16(&mut self, value: i16)

Writes an i16 value to the buffer in little-endian order.

Source

pub fn write_i32(&mut self, value: i32)

Writes an i32 value to the buffer in little-endian order.

Source

pub fn write_i64(&mut self, value: i64)

Writes an i64 value to the buffer in little-endian order.

Source

pub fn write_f32(&mut self, value: f32)

Writes a f32 value to the buffer in little-endian order.

Source

pub fn write_f64(&mut self, value: f64)

Writes a f64 value to the buffer in little-endian order.

Source

pub fn write_bool(&mut self, value: bool)

Writes a bool value to the buffer as a single byte (0 or 1).

Source

pub fn write_string(&mut self, value: &str)

Writes a string to the buffer. First writes the length as u32, then the UTF-8 bytes.

Source

pub fn write_vec_u8(&mut self, value: &[u8])

Writes a vector of u8 to the buffer. First writes the length as u32, then the bytes.

Source

pub fn write_vec_u16(&mut self, value: &[u16])

Writes a vector of u16 to the buffer. First writes the length as u32, then the bytes in little-endian.

Source

pub fn write_vec_u32(&mut self, value: &[u32])

Writes a vector of u32 to the buffer. First writes the length as u32, then the bytes in little-endian.

Source

pub fn write_vec_u64(&mut self, value: &[u64])

Writes a vector of u64 to the buffer. First writes the length as u32, then the bytes in little-endian.

Source

pub fn write_vec_i8(&mut self, value: &[i8])

Writes a vector of i8 to the buffer. First writes the length as u32, then the bytes.

Source

pub fn write_vec_i16(&mut self, value: &[i16])

Writes a vector of i16 to the buffer. First writes the length as u32, then the bytes in little-endian.

Source

pub fn write_vec_i32(&mut self, value: &[i32])

Writes a vector of i32 to the buffer. First writes the length as u32, then the bytes in little-endian.

Source

pub fn write_vec_i64(&mut self, value: &[i64])

Writes a vector of i64 to the buffer. First writes the length as u32, then the bytes in little-endian.

Source

pub fn write_vec_f32(&mut self, value: &[f32])

Writes a vector of f32 to the buffer. First writes the length as u32, then the bytes in little-endian.

Source

pub fn write_vec_f64(&mut self, value: &[f64])

Writes a vector of f64 to the buffer. First writes the length as u32, then the bytes in little-endian.

Source

pub fn write_vec_string(&mut self, value: &[String])

Writes a vector of strings to the buffer. First writes the length as u32, then each string serialized.

Auto Trait Implementations§

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.