Struct disk::qcow::refcount::RefCount

source ·
pub struct RefCount {
    ref_table: VecCache<u64>,
    refcount_table_offset: u64,
    refblock_cache: CacheMap<VecCache<u16>>,
    refcount_block_entries: u64,
    cluster_size: u64,
    max_valid_cluster_offset: u64,
}
Expand description

Represents the refcount entries for an open qcow file.

Fields§

§ref_table: VecCache<u64>§refcount_table_offset: u64§refblock_cache: CacheMap<VecCache<u16>>§refcount_block_entries: u64§cluster_size: u64§max_valid_cluster_offset: u64

Implementations§

source§

impl RefCount

source

pub fn new( raw_file: &mut QcowRawFile, refcount_table_offset: u64, refcount_table_entries: u64, refcount_block_entries: u64, cluster_size: u64 ) -> Result<RefCount>

Creates a RefCount from file, reading the refcount table from refcount_table_offset. refcount_table_entries specifies the number of refcount blocks used by this image. refcount_block_entries indicates the number of refcounts in each refcount block. Each refcount table entry points to a refcount block.

source

pub fn refcounts_per_block(&self) -> u64

Returns the number of refcounts per block.

source

pub fn max_valid_cluster_offset(&self) -> u64

Returns the maximum valid cluster offset in the raw file for this refcount table.

source

pub fn set_cluster_refcount( &mut self, raw_file: &mut QcowRawFile, cluster_address: u64, refcount: u16, new_cluster: Option<(u64, VecCache<u16>)> ) -> Result<Option<u64>, Error>

Returns NeedNewCluster if a new cluster needs to be allocated for refcounts. If an existing cluster needs to be read, NeedCluster(addr) is returned. The Caller should allocate a cluster or read the required one and call this function again with the cluster. On success, an optional address of a dropped cluster is returned. The dropped cluster can be reused for other purposes.

source

pub fn flush_blocks(&mut self, raw_file: &mut QcowRawFile) -> Result<()>

Flush the dirty refcount blocks. This must be done before flushing the table that points to the blocks.

source

pub fn flush_table(&mut self, raw_file: &mut QcowRawFile) -> Result<bool>

Flush the refcount table that keeps the address of the refcounts blocks. Returns true if the table changed since the previous flush_table() call.

source

pub fn get_cluster_refcount( &mut self, raw_file: &mut QcowRawFile, address: u64 ) -> Result<u16, Error>

Gets the refcount for a cluster with the given address.

source

fn get_refcount_index(&self, address: u64) -> (usize, usize)

Trait Implementations§

source§

impl Debug for RefCount

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.