Trait Write
pub trait Write: Sized {
Show 13 methods
// Required method
fn write_all(&mut self, buf: &[u8]);
// Provided methods
fn write_u8(&mut self, value: u8) { ... }
fn write_u16(&mut self, num: u16) { ... }
fn write_u32(&mut self, num: u32) { ... }
fn write_u32_be(&mut self, num: u32) { ... }
fn write_var<T>(&mut self, num: T)
where T: VarInt { ... }
fn write_var_signed<T>(&mut self, num: &Signed<T>)
where T: SignedVarInt { ... }
fn write_buf<B>(&mut self, buf: B)
where B: AsRef<[u8]> { ... }
fn write_string(&mut self, str: &str) { ... }
fn write_f32(&mut self, num: f32) { ... }
fn write_f64(&mut self, num: f64) { ... }
fn write_i64(&mut self, num: i64) { ... }
fn write_u64(&mut self, num: u64) { ... }
}Required Methods§
Provided Methods§
fn write_u8(&mut self, value: u8)
fn write_u32_be(&mut self, num: u32)
fn write_u32_be(&mut self, num: u32)
Write an unsigned integer (32bit) in big endian order (most significant byte first)
fn write_var<T>(&mut self, num: T)where
T: VarInt,
fn write_var<T>(&mut self, num: T)where
T: VarInt,
Write a variable length integer or unsigned integer.
We don’t use zig-zag encoding because we want to keep the option open to use the same function for BigInt and 53bit integers.
We use the 7th bit instead for signaling that this is a negative number.
fn write_var_signed<T>(&mut self, num: &Signed<T>)where
T: SignedVarInt,
fn write_var_signed<T>(&mut self, num: &Signed<T>)where
T: SignedVarInt,
Write a variable length integer or unsigned integer.
We don’t use zig-zag encoding because we want to keep the option open to use the same function for BigInt and 53bit integers.
We use the 7th bit instead for signaling that this is a negative number.
fn write_buf<B>(&mut self, buf: B)
fn write_buf<B>(&mut self, buf: B)
Write variable length buffer (binary content).
fn write_string(&mut self, str: &str)
fn write_string(&mut self, str: &str)
Write variable-length utf8 string
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.