pub struct BinaryWriter { /* private fields */ }
Expand description
BinaryWriter is used to serialize various data types into a byte buffer.
Implementations§
Source§impl BinaryWriter
impl BinaryWriter
Sourcepub fn write_u16(&mut self, value: u16)
pub fn write_u16(&mut self, value: u16)
Writes a u16 value to the buffer in little-endian order.
Sourcepub fn write_u32(&mut self, value: u32)
pub fn write_u32(&mut self, value: u32)
Writes a u32 value to the buffer in little-endian order.
Sourcepub fn write_u64(&mut self, value: u64)
pub fn write_u64(&mut self, value: u64)
Writes a u64 value to the buffer in little-endian order.
Sourcepub fn write_i16(&mut self, value: i16)
pub fn write_i16(&mut self, value: i16)
Writes an i16 value to the buffer in little-endian order.
Sourcepub fn write_i32(&mut self, value: i32)
pub fn write_i32(&mut self, value: i32)
Writes an i32 value to the buffer in little-endian order.
Sourcepub fn write_i64(&mut self, value: i64)
pub fn write_i64(&mut self, value: i64)
Writes an i64 value to the buffer in little-endian order.
Sourcepub fn write_f32(&mut self, value: f32)
pub fn write_f32(&mut self, value: f32)
Writes a f32 value to the buffer in little-endian order.
Sourcepub fn write_f64(&mut self, value: f64)
pub fn write_f64(&mut self, value: f64)
Writes a f64 value to the buffer in little-endian order.
Sourcepub fn write_bool(&mut self, value: bool)
pub fn write_bool(&mut self, value: bool)
Writes a bool value to the buffer as a single byte (0 or 1).
Sourcepub fn write_string(&mut self, value: &str)
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.
Sourcepub fn write_vec_u8(&mut self, value: &[u8])
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.
Sourcepub fn write_vec_u16(&mut self, value: &[u16])
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.
Sourcepub fn write_vec_u32(&mut self, value: &[u32])
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.
Sourcepub fn write_vec_u64(&mut self, value: &[u64])
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.
Sourcepub fn write_vec_i8(&mut self, value: &[i8])
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.
Sourcepub fn write_vec_i16(&mut self, value: &[i16])
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.
Sourcepub fn write_vec_i32(&mut self, value: &[i32])
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.
Sourcepub fn write_vec_i64(&mut self, value: &[i64])
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.
Sourcepub fn write_vec_f32(&mut self, value: &[f32])
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.
Sourcepub fn write_vec_f64(&mut self, value: &[f64])
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.
Sourcepub fn write_vec_string(&mut self, value: &[String])
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.