Trait ByteWriter

Source
pub trait ByteWriter {
    // Required methods
    fn write_byte(&mut self, b: u8);
    fn write_bytes(&mut self, v: &[u8]);

    // Provided methods
    fn writer_hint(&mut self, _expectedlen: usize) { ... }
    fn as_mut_vec(&mut self) -> Option<&mut Vec<u8>> { ... }
}
Expand description

Byte writer used by encoders. In most cases this will be an owned vector of u8.

Required Methods§

Source

fn write_byte(&mut self, b: u8)

Writes a single byte.

Source

fn write_bytes(&mut self, v: &[u8])

Writes a number of bytes.

Provided Methods§

Source

fn writer_hint(&mut self, _expectedlen: usize)

Hints an expected lower bound on the length (in bytes) of the output until the next call to writer_hint, so that the writer can reserve the memory for writing. RawEncoders are recommended but not required to call this method with an appropriate estimate. By default this method does nothing.

Source

fn as_mut_vec(&mut self) -> Option<&mut Vec<u8>>

If this ByteWriter is a Vec<u8>, returns a mutable reference to self as Some(&mut Vec<u8>). Returns None otherwise.

Implementations on Foreign Types§

Source§

impl ByteWriter for Vec<u8>

Source§

fn writer_hint(&mut self, expectedlen: usize)

Source§

fn write_byte(&mut self, b: u8)

Source§

fn write_bytes(&mut self, v: &[u8])

Source§

fn as_mut_vec(&mut self) -> Option<&mut Vec<u8>>

Implementors§