pub struct CompositeDiskFile {
    component_disks: Vec<ComponentDiskPart>,
}
Expand description

Represents a composite virtual disk made out of multiple component files. This is described on disk by a protocol buffer file that lists out the component file locations and their offsets and lengths on the virtual disk. The spaces covered by the component disks must be contiguous and not overlapping.

Fields§

§component_disks: Vec<ComponentDiskPart>

Implementations§

source§

impl CompositeDiskFile

source

fn new(disks: Vec<ComponentDiskPart>) -> Result<CompositeDiskFile, Error>

source

pub fn from_file( file: File, is_sparse_file: bool, max_nesting_depth: u32, image_path: &Path ) -> Result<CompositeDiskFile, Error>

Set up a composite disk by reading the specification from a file. The file must consist of the CDISK_MAGIC string followed by one binary instance of the CompositeDisk protocol buffer. Returns an error if it could not read the file or if the specification was invalid.

source

fn length(&self) -> u64

source

fn disk_at_offset(&self, offset: u64) -> Result<&ComponentDiskPart>

Trait Implementations§

source§

impl AsRawDescriptors for CompositeDiskFile

source§

fn as_raw_descriptors(&self) -> Vec<RawDescriptor>

Returns the underlying raw descriptors. Read more
source§

impl Debug for CompositeDiskFile

source§

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

Formats the value using the given formatter. Read more
source§

impl DiskFile for CompositeDiskFile

source§

fn try_clone(&self) -> Result<Box<dyn DiskFile>>

Creates a new DiskFile instance that shares the same underlying disk file image. IO operations to a DiskFile should affect all DiskFile instances with the same underlying disk file image. Read more
source§

impl DiskGetLen for CompositeDiskFile

source§

fn get_len(&self) -> Result<u64>

Get the current length of the disk in bytes.
source§

impl FileReadWriteAtVolatile for CompositeDiskFile

source§

fn read_at_volatile( &self, slice: VolatileSlice<'_>, offset: u64 ) -> Result<usize>

Reads bytes from this file at offset into the given slice, returning the number of bytes read on success. On Windows file pointer will update with the read, but on Linux the file pointer will not change.
source§

fn write_at_volatile( &self, slice: VolatileSlice<'_>, offset: u64 ) -> Result<usize>

Writes bytes to this file at offset from the given slice, returning the number of bytes written on success. On Windows file pointer will update with the write, but on Linux the file pointer will not change.
§

fn read_vectored_at_volatile( &self, bufs: &[VolatileSlice<'_>], offset: u64 ) -> Result<usize, Error>

Like read_at_volatile, except it reads to a slice of buffers. Data is copied to fill each buffer in order, with the final buffer written to possibly being only partially filled. This method must behave as a single call to read_at_volatile with the buffers concatenated would. The default implementation calls read_at_volatile with either the first nonempty buffer provided, or returns Ok(0) if none exists. On Windows file pointer will update with the read, but on Linux the file pointer will not change.
§

fn read_exact_at_volatile( &self, slice: VolatileSlice<'_>, offset: u64 ) -> Result<(), Error>

Reads bytes from this file at offset into the given slice until all bytes in the slice are read, or an error is returned. On Windows file pointer will update with the read, but on Linux the file pointer will not change.
§

fn write_vectored_at_volatile( &self, bufs: &[VolatileSlice<'_>], offset: u64 ) -> Result<usize, Error>

Like write_at_volatile, except that it writes from a slice of buffers. Data is copied from each buffer in order, with the final buffer read from possibly being only partially consumed. This method must behave as a call to write_at_volatile with the buffers concatenated would. The default implementation calls write_at_volatile with either the first nonempty buffer provided, or returns Ok(0) if none exists. On Windows file pointer will update with the write, but on Linux the file pointer will not change.
§

fn write_all_at_volatile( &self, slice: VolatileSlice<'_>, offset: u64 ) -> Result<(), Error>

Writes bytes to this file at offset from the given slice until all bytes in the slice are written, or an error is returned. On Windows file pointer will update with the write, but on Linux the file pointer will not change.
source§

impl FileSetLen for CompositeDiskFile

source§

fn set_len(&self, _len: u64) -> Result<()>

source§

impl ToAsyncDisk for CompositeDiskFile

source§

fn to_async_disk(self: Box<Self>, ex: &Executor) -> Result<Box<dyn AsyncDisk>>

Convert a boxed self in to a box-wrapped implementaiton of AsyncDisk. Used to convert a standard disk image to an async disk image. This conversion and the inverse are needed so that the Send DiskImage can be given to the block thread where it is converted to a non-Send AsyncDisk. The AsyncDisk can then be converted back and returned to the main device thread if the block device is destroyed or reset.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.