Struct disk::qcow::qcow_raw_file::QcowRawFile
source · pub struct QcowRawFile {
file: File,
cluster_size: u64,
cluster_mask: u64,
}
Expand description
A qcow file. Allows reading/writing clusters and appending clusters.
Fields§
§file: File
§cluster_size: u64
§cluster_mask: u64
Implementations§
source§impl QcowRawFile
impl QcowRawFile
sourcepub fn from(file: File, cluster_size: u64) -> Option<Self>
pub fn from(file: File, cluster_size: u64) -> Option<Self>
Creates a QcowRawFile
from the given File
, None
is returned if cluster_size
is not
a power of two.
sourcepub fn read_pointer_table(
&mut self,
offset: u64,
count: u64,
mask: Option<u64>
) -> Result<Vec<u64>>
pub fn read_pointer_table( &mut self, offset: u64, count: u64, mask: Option<u64> ) -> Result<Vec<u64>>
Reads count
64 bit offsets and returns them as a vector.
mask
optionally ands out some of the bits on the file.
sourcepub fn read_pointer_cluster(
&mut self,
offset: u64,
mask: Option<u64>
) -> Result<Vec<u64>>
pub fn read_pointer_cluster( &mut self, offset: u64, mask: Option<u64> ) -> Result<Vec<u64>>
Reads a cluster’s worth of 64 bit offsets and returns them as a vector.
mask
optionally ands out some of the bits on the file.
sourcepub fn write_pointer_table(
&mut self,
offset: u64,
table: &[u64],
non_zero_flags: u64
) -> Result<()>
pub fn write_pointer_table( &mut self, offset: u64, table: &[u64], non_zero_flags: u64 ) -> Result<()>
Writes table
of u64 pointers to offset
in the file.
non_zero_flags
will be ORed with all non-zero values in table
.
writing.
sourcepub fn read_refcount_block(&mut self, offset: u64) -> Result<Vec<u16>>
pub fn read_refcount_block(&mut self, offset: u64) -> Result<Vec<u16>>
Read a refcount block from the file and returns a Vec containing the block. Always returns a cluster’s worth of data.
sourcepub fn write_refcount_block(&mut self, offset: u64, table: &[u16]) -> Result<()>
pub fn write_refcount_block(&mut self, offset: u64, table: &[u16]) -> Result<()>
Writes a refcount block to the file.
sourcepub fn add_cluster_end(
&mut self,
max_valid_cluster_offset: u64
) -> Result<Option<u64>>
pub fn add_cluster_end( &mut self, max_valid_cluster_offset: u64 ) -> Result<Option<u64>>
Allocates a new cluster at the end of the current file, return the address.
sourcepub fn cluster_size(&self) -> u64
pub fn cluster_size(&self) -> u64
Returns the size of the file’s clusters.
sourcepub fn cluster_offset(&self, address: u64) -> u64
pub fn cluster_offset(&self, address: u64) -> u64
Returns the offset of address
within a cluster.
sourcepub fn zero_cluster(&mut self, address: u64) -> Result<()>
pub fn zero_cluster(&mut self, address: u64) -> Result<()>
Zeros out a cluster in the file.