pub struct BitQueue<E: Endianness, N: Numeric> { /* private fields */ }
Expand description
A queue for efficiently pushing bits onto a value and popping them off a value.
Implementations§
Source§impl<E: Endianness, N: Numeric> BitQueue<E, N>
impl<E: Endianness, N: Numeric> BitQueue<E, N>
Sourcepub fn from_value(value: N, bits: u32) -> BitQueue<E, N>
pub 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.
Sourcepub fn set(&mut self, value: N, bits: u32)
pub fn set(&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
Sourcepub fn remaining_len(&self) -> u32
pub fn remaining_len(&self) -> u32
Returns the remaining bits the queue can hold
Sourcepub fn push(&mut self, bits: u32, value: N)
pub fn push(&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.
Sourcepub fn push_fixed<const B: u32>(&mut self, value: N)
pub fn push_fixed<const B: u32>(&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.
Sourcepub fn pop(&mut self, bits: u32) -> N
pub fn pop(&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.
Sourcepub fn pop_fixed<const B: u32>(&mut self) -> N
pub fn pop_fixed<const B: u32>(&mut self) -> N
Pops a value with the given number of bits from the head of the queue
Sourcepub fn pop_all(&mut self) -> N
pub fn pop_all(&mut self) -> N
Pops all the current bits from the queue and resets it to an empty state.
Sourcepub fn drop(&mut self, bits: u32)
pub fn drop(&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.
Trait Implementations§
Auto Trait Implementations§
impl<E, N> Freeze for BitQueue<E, N>where
N: Freeze,
impl<E, N> RefUnwindSafe for BitQueue<E, N>where
N: RefUnwindSafe,
E: RefUnwindSafe,
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> UnwindSafe for BitQueue<E, N>where
N: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)