pub(super) struct RefBlock {
cluster: Option<HostCluster>,
raw_data: IoBuffer,
refcount_order: u32,
cluster_bits: u32,
modified: AtomicBool,
writer_lock: Mutex<()>,
}
Expand description
Refcount block.
Fields§
§cluster: Option<HostCluster>
Cluster in the image file.
raw_data: IoBuffer
Raw table data (big endian).
refcount_order: u32
log2 of the refcount bits.
cluster_bits: u32
log2 of the cluster size.
modified: AtomicBool
Whether this block has been modified since it was last written.
writer_lock: Mutex<()>
Lock for creating RefBlockWriteGuard
.
Implementations§
Source§impl RefBlock
impl RefBlock
Sourcepub fn new_cleared<S: Storage>(for_image: &S, header: &Header) -> Result<Self>
pub fn new_cleared<S: Storage>(for_image: &S, header: &Header) -> Result<Self>
Create a new zeroed refcount block.
Sourcepub async fn load<S: Storage>(
image: &S,
header: &Header,
cluster: HostCluster,
) -> Result<Self>
pub async fn load<S: Storage>( image: &S, header: &Header, cluster: HostCluster, ) -> Result<Self>
Load a refcount block from disk.
Sourcepub fn get_cluster(&self) -> Option<HostCluster>
pub fn get_cluster(&self) -> Option<HostCluster>
Get the block’s cluster in the image file.
Sourcepub fn get_offset(&self) -> Option<HostOffset>
pub fn get_offset(&self) -> Option<HostOffset>
Get the block’s offset in the image file.
Sourcepub fn set_cluster(&mut self, cluster: HostCluster)
pub fn set_cluster(&mut self, cluster: HostCluster)
Change the block’s cluster in the image file (for writing).
Sourcefn sub_byte_refcount_access(&self, index: usize) -> (usize, u8, usize)
fn sub_byte_refcount_access(&self, index: usize) -> (usize, u8, usize)
Calculate sub-byte refcount access parameters.
For a given refcount index, return its:
- byte index,
- access mask,
- in-byte shift.
Sourcepub async fn lock_write(&self) -> RefBlockWriteGuard<'_>
pub async fn lock_write(&self) -> RefBlockWriteGuard<'_>
Allow modifying this refcount block.
Note that readers are allowed to exist while modifications are happening.
Sourcepub fn is_modified(&self) -> bool
pub fn is_modified(&self) -> bool
Check whether this block has been modified since it was last written.
Sourcepub fn clear_modified(&self)
pub fn clear_modified(&self)
Clear the modified flag.
Sourcepub fn set_modified(&self)
pub fn set_modified(&self)
Set the modified flag.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RefBlock
impl !RefUnwindSafe for RefBlock
impl Send for RefBlock
impl Sync for RefBlock
impl Unpin for RefBlock
impl UnwindSafe for RefBlock
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