Skip to main content

DirtyBitMap

Type Alias DirtyBitMap 

Source
pub type DirtyBitMap<const N: usize> = BitMap<N, Dirty<N>>;
Expand description

Type alias for a dirty bitmap with pending mutations.

Aliased Type§

pub struct DirtyBitMap<const N: usize> { /* private fields */ }

Implementations§

Source§

impl<const N: usize> DirtyBitMap<N>

Source

pub const fn len(&self) -> u64

Get the length of the bitmap as it would be after committing.

Source

pub const fn is_empty(&self) -> bool

Returns true if the bitmap would be empty after committing.

Source

pub const fn pruned_chunks(&self) -> usize

Get the number of pruned chunks after committing.

Source

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

Get a bit value with read-through semantics.

Returns the bit’s value as it would be after committing. Priority: appended bits > modified bits > original bitmap.

§Panics

Panics if the bit offset is out of bounds or if the bit has been pruned.

Source

pub fn get_chunk(&self, bit: u64) -> [u8; N]

Get a chunk value with read-through semantics.

Reconstructs the chunk if it has modifications, otherwise returns from current.

§Panics

Panics if the bit offset is out of bounds or if the chunk has been pruned.

Source

pub fn set_bit(&mut self, bit: u64, value: bool) -> &mut Self

Set a bit value.

§Panics

Panics if the bit offset is out of bounds or if the bit has been pruned.

Source

pub fn push(&mut self, bit: bool) -> &mut Self

Push a bit to the end of the bitmap.

Source

pub fn push_byte(&mut self, byte: u8) -> &mut Self

Push a byte to the end of the bitmap.

Source

pub fn push_chunk(&mut self, chunk: &[u8; N]) -> &mut Self

Push a full chunk to the end of the bitmap.

Source

pub fn pop(&mut self) -> bool

Pop the last bit from the bitmap.

Returns the value of the popped bit, accounting for any modifications.

§Panics

Panics if the bitmap is empty.

Source

pub fn prune_to_bit(&mut self, bit: u64) -> &mut Self

Prune chunks up to the chunk containing the given bit offset.

Note: bit can equal projected_len when pruning at a chunk boundary.

§Panics

Panics if bit is > the projected length.

Source

pub fn commit(self, commit_number: u64) -> Result<CleanBitMap<N>, Error>

Commit the changes and return a clean bitmap with a historical snapshot.

§Errors

Returns Error::NonMonotonicCommit if the commit number is not greater than the previous commit.

Returns Error::ReservedCommitNumber if the commit number is u64::MAX.

Source

pub fn abort(self) -> CleanBitMap<N>

Abort the changes and return to clean state.

All pending mutations are discarded.