pub trait ByteWriter: Sized {
// Required methods
fn write_u8(&mut self, value: u8);
fn write_bytes(&mut self, values: &[u8]);
// Provided methods
fn write_bool(&mut self, val: bool) { ... }
fn write_u16(&mut self, value: u16) { ... }
fn write_u32(&mut self, value: u32) { ... }
fn write_u64(&mut self, value: u64) { ... }
fn write_u128(&mut self, value: u128) { ... }
fn write_usize(&mut self, value: usize) { ... }
fn write<S>(&mut self, value: S)
where S: Serializable { ... }
fn write_many<S, T>(&mut self, elements: T)
where T: IntoIterator<Item = S>,
S: Serializable { ... }
}Expand description
Defines how primitive values are to be written into Self.
Required Methods§
Sourcefn write_bytes(&mut self, values: &[u8])
fn write_bytes(&mut self, values: &[u8])
Writes a sequence of bytes into self.
§Panics
Panics if the sequence of bytes could not be written into self.
Provided Methods§
Sourcefn write_bool(&mut self, val: bool)
fn write_bool(&mut self, val: bool)
Writes a boolean value into self.
A boolean value is written as a single byte.
§Panics
Panics if the value could not be written into self.
Sourcefn write_u16(&mut self, value: u16)
fn write_u16(&mut self, value: u16)
Writes a u16 value in little-endian byte order into self.
§Panics
Panics if the value could not be written into self.
Sourcefn write_u32(&mut self, value: u32)
fn write_u32(&mut self, value: u32)
Writes a u32 value in little-endian byte order into self.
§Panics
Panics if the value could not be written into self.
Sourcefn write_u64(&mut self, value: u64)
fn write_u64(&mut self, value: u64)
Writes a u64 value in little-endian byte order into self.
§Panics
Panics if the value could not be written into self.
Sourcefn write_u128(&mut self, value: u128)
fn write_u128(&mut self, value: u128)
Writes a u128 value in little-endian byte order into self.
§Panics
Panics if the value could not be written into self.
Sourcefn write_usize(&mut self, value: usize)
fn write_usize(&mut self, value: usize)
Sourcefn write<S>(&mut self, value: S)where
S: Serializable,
fn write<S>(&mut self, value: S)where
S: Serializable,
Sourcefn write_many<S, T>(&mut self, elements: T)where
T: IntoIterator<Item = S>,
S: Serializable,
fn write_many<S, T>(&mut self, elements: T)where
T: IntoIterator<Item = S>,
S: Serializable,
Serializes all elements and writes the resulting bytes into self.
This method does not write any metadata (e.g. number of serialized elements) into self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.