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>
impl<const N: usize> DirtyBitMap<N>
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if the bitmap would be empty after committing.
Sourcepub const fn pruned_chunks(&self) -> usize
pub const fn pruned_chunks(&self) -> usize
Get the number of pruned chunks after committing.
Sourcepub fn get_bit(&self, bit: u64) -> bool
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.
Sourcepub fn get_chunk(&self, bit: u64) -> [u8; N]
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.
Sourcepub fn push_chunk(&mut self, chunk: &[u8; N]) -> &mut Self
pub fn push_chunk(&mut self, chunk: &[u8; N]) -> &mut Self
Push a full chunk to the end of the bitmap.
Sourcepub fn pop(&mut self) -> bool
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.
Sourcepub fn prune_to_bit(&mut self, bit: u64) -> &mut Self
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.
Sourcepub fn commit(self, commit_number: u64) -> Result<CleanBitMap<N>, Error>
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.
Sourcepub fn abort(self) -> CleanBitMap<N>
pub fn abort(self) -> CleanBitMap<N>
Abort the changes and return to clean state.
All pending mutations are discarded.