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: IoBufferRaw table data (big endian).
refcount_order: u32log2 of the refcount bits.
cluster_bits: u32log2 of the cluster size.
modified: AtomicBoolWhether 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.
Sourcefn copy_raw_data<T: Copy + Sized, F: Fn(*const T) -> T>(
&self,
mem_align: usize,
get: F,
) -> Result<IoBuffer>
fn copy_raw_data<T: Copy + Sized, F: Fn(*const T) -> T>( &self, mem_align: usize, get: F, ) -> Result<IoBuffer>
Copy data from self.raw_data using the get function.
mem_align is the minimum memory alignment for the returned buffer.
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.