pub struct Unpacker<B> { /* private fields */ }Expand description
Sequentially unpacks values from a buffer.
Each unpack call extracts the lower SIZE bits of the
buffer and shifts the remaining bits down, so values are extracted in
reverse order of how they were packed.
Most callers will not interact with Unpacker directly — the
#[packable] macro generates code that uses it.
§Example
use bitcram::Unpacker;
let mut unpacker = Unpacker::<u32>::new(0b1011);
assert_eq!(unpacker.raw_unpack(1), 0b1);
assert_eq!(unpacker.raw_unpack(3), 0b101);Implementations§
Source§impl<B: Buffer> Unpacker<B>
impl<B: Buffer> Unpacker<B>
Sourcepub fn unpack<P: Packable<B>>(&mut self) -> P
pub fn unpack<P: Packable<B>>(&mut self) -> P
Extracts a value from the buffer using its Packable implementation.
Sourcepub fn raw_unpack(&mut self, size: u32) -> B
pub fn raw_unpack(&mut self, size: u32) -> B
Extracts the lower size bits of the buffer and advances past them.
size must satisfy size < B::BITS. Reading exactly B::BITS of
data requires multiple calls each smaller than B::BITS.
Sourcepub fn into_inner(self) -> B
pub fn into_inner(self) -> B
Consumes the unpacker and returns the remaining buffer state.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for Unpacker<B>where
B: Freeze,
impl<B> RefUnwindSafe for Unpacker<B>where
B: RefUnwindSafe,
impl<B> Send for Unpacker<B>where
B: Send,
impl<B> Sync for Unpacker<B>where
B: Sync,
impl<B> Unpin for Unpacker<B>where
B: Unpin,
impl<B> UnsafeUnpin for Unpacker<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for Unpacker<B>where
B: 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
Mutably borrows from an owned value. Read more