Struct BitQueue

struct BitQueue<E: Endianness, N: Numeric> { ... }

A queue for efficiently pushing bits onto a value and popping them off a value.

Implementations

impl<E: Endianness> BitQueue<E, u8>

fn to_state(self: &Self) -> usize

Returns the state of the queue as a single value which can be used to perform lookups.

impl<E: Endianness, N: Numeric> BitQueue<E, N>

fn new() -> BitQueue<E, N>

Returns a new empty queue

fn from_value(value: N, bits: u32) -> BitQueue<E, N>

Creates a new queue from the given value with the given size Panics if the value is larger than the given number of bits.

fn set(self: &mut Self, value: N, bits: u32)

Sets the queue to a given value with the given number of bits Panics if the value is larger than the given number of bits

fn value(self: Self) -> N

Consumes the queue and returns its current value

fn len(self: &Self) -> u32

Returns the total bits in the queue

fn max_len(self: &Self) -> u32

Returns the maximum bits the queue can hold

fn remaining_len(self: &Self) -> u32

Returns the remaining bits the queue can hold

fn is_empty(self: &Self) -> bool

Returns true if the queue is empty

fn is_full(self: &Self) -> bool

Returns true if the queue is full

fn clear(self: &mut Self)

Drops all values in the queue

fn all_0(self: &Self) -> bool

Returns true if all bits remaining in the queue are 0

fn all_1(self: &Self) -> bool

Returns true if all bits remaining in the queue are 1

fn push(self: &mut Self, bits: u32, value: N)

Pushes a value with the given number of bits onto the tail of the queue Panics if the number of bits pushed is larger than the queue can hold.

fn push_fixed<B: u32>(self: &mut Self, value: N)

Pushes a value with the given number of bits onto the tail of the queue Panics if the number of bits pushed is larger than the queue can hold.

fn pop(self: &mut Self, bits: u32) -> N

Pops a value with the given number of bits from the head of the queue Panics if the number of bits popped is larger than the number of bits in the queue.

fn pop_fixed<B: u32>(self: &mut Self) -> N

Pops a value with the given number of bits from the head of the queue

fn pop_all(self: &mut Self) -> N

Pops all the current bits from the queue and resets it to an empty state.

fn drop(self: &mut Self, bits: u32)

Drops the given number of bits from the head of the queue without returning them. Panics if the number of bits dropped is larger than the number of bits in the queue.

fn pop_0(self: &mut Self) -> u32

Pops all 0 bits up to and including the next 1 bit and returns the amount of 0 bits popped

fn pop_1(self: &mut Self) -> u32

Pops all 1 bits up to and including the next 0 bit and returns the amount of 1 bits popped

impl<E, N> Freeze for BitQueue<E, N>

impl<E, N> RefUnwindSafe for BitQueue<E, N>

impl<E, N> Send for BitQueue<E, N>

impl<E, N> Sync for BitQueue<E, N>

impl<E, N> Unpin for BitQueue<E, N>

impl<E, N> UnsafeUnpin for BitQueue<E, N>

impl<E, N> UnwindSafe for BitQueue<E, N>

impl<E: $crate::clone::Clone + Endianness, N: $crate::clone::Clone + Numeric> Clone for BitQueue<E, N>

fn clone(self: &Self) -> BitQueue<E, N>

impl<E: $crate::default::Default + Endianness, N: $crate::default::Default + Numeric> Default for BitQueue<E, N>

fn default() -> BitQueue<E, N>

impl<E: $crate::fmt::Debug + Endianness, N: $crate::fmt::Debug + Numeric> Debug for BitQueue<E, N>

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

impl<T> Any for BitQueue<E, N>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for BitQueue<E, N>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for BitQueue<E, N>

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

impl<T> CloneToUninit for BitQueue<E, N>

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

impl<T> From for BitQueue<E, N>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for BitQueue<E, N>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for BitQueue<E, N>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for BitQueue<E, N>

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

impl<T, U> TryInto for BitQueue<E, N>

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