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

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn write_refcount_block(&mut self, offset: u64, table: &[u16]) -> Result<()>

Writes a refcount block to the file.

source

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.

source

pub fn file(&self) -> &File

Returns a reference to the underlying file.

source

pub fn file_mut(&mut self) -> &mut File

Returns a mutable reference to the underlying file.

source

pub fn cluster_size(&self) -> u64

Returns the size of the file’s clusters.

source

pub fn cluster_offset(&self, address: u64) -> u64

Returns the offset of address within a cluster.

source

pub fn zero_cluster(&mut self, address: u64) -> Result<()>

Zeros out a cluster in the file.

source

pub fn write_cluster( &mut self, address: u64, initial_data: Vec<u8> ) -> Result<()>

Writes

Trait Implementations§

source§

impl Debug for QcowRawFile

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.