Skip to main content

BitVecWriter

Struct BitVecWriter 

Source
pub struct BitVecWriter { /* private fields */ }
Expand description

A growable bit-level writer backed by a Vec<u8>.

Implementations§

Source§

impl BitVecWriter

Source

pub fn new() -> Self

Creates a new empty BitVecWriter.

Source

pub fn with_capacity(bytes: usize) -> Self

Creates a new BitVecWriter with pre-allocated capacity.

Source

pub const fn bits_written(&self) -> usize

Returns the number of bits written so far.

Source

pub fn write_bit(&mut self, value: bool)

Writes a single bit.

Source

pub fn write_bits(&mut self, value: u64, bits: u8) -> BitResult<()>

Writes up to 64 bits from an unsigned integer.

Source

pub fn align_to_byte(&mut self)

Pads with zero bits until the next byte boundary.

Source

pub fn write_u8_aligned(&mut self, value: u8) -> BitResult<()>

Writes a byte-aligned u8.

Source

pub fn write_u16_aligned(&mut self, value: u16) -> BitResult<()>

Writes a byte-aligned u16 (little-endian).

Source

pub fn write_u32_aligned(&mut self, value: u32) -> BitResult<()>

Writes a byte-aligned u32 (little-endian).

Source

pub fn write_u64_aligned(&mut self, value: u64) -> BitResult<()>

Writes a byte-aligned u64 (little-endian).

Source

pub fn write_varu32(&mut self, value: u32) -> BitResult<()>

Writes a byte-aligned varint u32.

Source

pub fn write_vars32(&mut self, value: i32) -> BitResult<()>

Writes a byte-aligned zigzag varint i32.

Source

pub fn finish(self) -> Vec<u8>

Finishes writing and returns the byte buffer.

Trait Implementations§

Source§

impl Debug for BitVecWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BitVecWriter

Source§

fn default() -> BitVecWriter

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.