Struct BitBuffer

Source
pub struct BitBuffer<Inner = BitVector> { /* private fields */ }
Expand description

A bit buffer can be used to read bits from or write bits to an underlying bit vector.

Implementations§

Source§

impl<Block: BlockType> BitBuffer<BitVector<Block>>

Source

pub fn new() -> Self

Creates a new, empty bit buffer.

Source

pub fn with_capacity(capacity: u64) -> Self

Creates a new, empty bit buffer with the given capacity (in bits) preallocated.

Source§

impl<Inner: BitVec> BitBuffer<Inner>

Source

pub fn from(input: Inner) -> Self

Creates a new bit buffer for reading from a bit vector.

Source

pub fn append(vec: Inner) -> Self

Creates a new bit buffer for appending to a bit vector.

Source

pub fn seek(&mut self, position: u64) -> Result<()>

Moves the position for the next read or write.

Source§

impl<Inner> BitBuffer<Inner>

Source

pub fn into_inner(self) -> Inner

Returns the bit vector underlying the bit buffer.

Source

pub fn inner(&self) -> &Inner

Gives access to the bit vector underlying the bit buffer.

Source

pub fn position(&self) -> u64

The position in the bit buffer where the next read or write will occur.

Trait Implementations§

Source§

impl<Inner: BitVec> BitRead for BitBuffer<Inner>

Source§

fn read_bit(&mut self) -> Result<Option<bool>>

Reads a single bit from the source. Read more
Source§

fn read_int<N: PrimInt>(&mut self, nbits: usize) -> Result<Option<N>>

Reads nbits bits as an integer, least-significant bit first.
Source§

fn read_int_be<N: PrimInt>(&mut self, nbits: usize) -> Result<Option<N>>

Reads nbits bits as an integer, most-significant bit first.
Source§

impl<Inner: BitVec> BitVec for BitBuffer<Inner>

Source§

type Block = <Inner as BitVec>::Block

The underlying block type used to store the bits of the vector.
Source§

fn block_len(&self) -> usize

The length of the slice in blocks.
Source§

fn bit_len(&self) -> u64

The length of the slice in bits.
Source§

fn get_block(&self, position: usize) -> Self::Block

Gets the block at position Read more
Source§

fn get_bit(&self, position: u64) -> bool

Gets the bit at position Read more
Source§

fn get_bits(&self, start: u64, count: usize) -> Self::Block

Gets count bits starting at bit index start, interpreted as a little-endian integer. Read more
Source§

impl<Inner: BitVecMut> BitVecMut for BitBuffer<Inner>

Source§

fn set_block(&mut self, position: usize, value: Self::Block)

Sets the block at position to value. Read more
Source§

fn set_bit(&mut self, position: u64, value: bool)

Sets the bit at position to value. Read more
Source§

fn set_bits(&mut self, start: u64, count: usize, value: Self::Block)

Sets count bits starting at bit index start, interpreted as a little-endian integer. Read more
Source§

impl<Inner: BitVecPush> BitWrite for BitBuffer<Inner>

Source§

fn write_bit(&mut self, value: bool) -> Result<()>

Writes a single bit to the sink.
Source§

fn write_int<N: PrimInt>(&mut self, nbits: usize, value: N) -> Result<()>

Writes the lower nbits of value, least-significant first.
Source§

fn write_int_be<N: PrimInt>(&mut self, nbits: usize, value: N) -> Result<()>

Writes the lower nbits of value, most-significant first.
Source§

impl<Inner: Clone> Clone for BitBuffer<Inner>

Source§

fn clone(&self) -> BitBuffer<Inner>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Inner: Debug> Debug for BitBuffer<Inner>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Inner> Freeze for BitBuffer<Inner>
where Inner: Freeze,

§

impl<Inner> RefUnwindSafe for BitBuffer<Inner>
where Inner: RefUnwindSafe,

§

impl<Inner> Send for BitBuffer<Inner>
where Inner: Send,

§

impl<Inner> Sync for BitBuffer<Inner>
where Inner: Sync,

§

impl<Inner> Unpin for BitBuffer<Inner>
where Inner: Unpin,

§

impl<Inner> UnwindSafe for BitBuffer<Inner>
where Inner: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.