Skip to main content

WriteExt

Trait WriteExt 

Source
pub trait WriteExt: Write {
    // Provided methods
    fn emit_u8(&mut self, v: u8) -> Result<(), Error> { ... }
    fn emit_u16(&mut self, v: u16) -> Result<(), Error> { ... }
    fn emit_u32(&mut self, v: u32) -> Result<(), Error> { ... }
    fn emit_u64(&mut self, v: u64) -> Result<(), Error> { ... }
    fn emit_slice(&mut self, slice: &[u8]) -> Result<(), Error> { ... }
    fn emit_compact_size(
        &mut self,
        value: impl Into<u64>,
    ) -> Result<usize, Error> { ... }
}
Expand description

Utility trait to write some primitive values into our encoding format.

Provided Methods§

Source

fn emit_u8(&mut self, v: u8) -> Result<(), Error>

Write an 8-bit unsigned integer in little-endian.

Source

fn emit_u16(&mut self, v: u16) -> Result<(), Error>

Write a 16-bit unsigned integer in little-endian.

Source

fn emit_u32(&mut self, v: u32) -> Result<(), Error>

Write a 32-bit unsigned integer in little-endian.

Source

fn emit_u64(&mut self, v: u64) -> Result<(), Error>

Write a 64-bit unsigned integer in little-endian.

Source

fn emit_slice(&mut self, slice: &[u8]) -> Result<(), Error>

Write the entire slice to the writer.

Source

fn emit_compact_size(&mut self, value: impl Into<u64>) -> Result<usize, Error>

Write a value in compact size aka “VarInt” encoding.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<W: Write + ?Sized> WriteExt for W