Struct disk::composite::CompositeDiskFile
source · pub struct CompositeDiskFile {
component_disks: Vec<ComponentDiskPart>,
_disk_spec_file: File,
}
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>
§_disk_spec_file: File
Implementations§
source§impl CompositeDiskFile
impl CompositeDiskFile
fn new( disks: Vec<ComponentDiskPart>, disk_spec_file: File ) -> Result<CompositeDiskFile, Error>
sourcepub fn from_file(
file: File,
params: DiskFileParams
) -> Result<CompositeDiskFile, Error>
pub fn from_file( file: File, params: DiskFileParams ) -> 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.
fn length(&self) -> u64
fn disk_at_offset(&self, offset: u64) -> Result<&ComponentDiskPart>
Trait Implementations§
source§impl AsRawDescriptors for CompositeDiskFile
impl AsRawDescriptors for CompositeDiskFile
source§fn as_raw_descriptors(&self) -> Vec<RawDescriptor>
fn as_raw_descriptors(&self) -> Vec<RawDescriptor>
Returns the underlying raw descriptors. Read more
source§impl Debug for CompositeDiskFile
impl Debug for CompositeDiskFile
source§impl DiskFile for CompositeDiskFile
impl DiskFile for CompositeDiskFile
source§impl DiskGetLen for CompositeDiskFile
impl DiskGetLen for CompositeDiskFile
source§impl FileReadWriteAtVolatile for CompositeDiskFile
impl FileReadWriteAtVolatile for CompositeDiskFile
source§fn read_at_volatile(
&self,
slice: VolatileSlice<'_>,
offset: u64
) -> Result<usize>
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>
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>
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>
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>
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>
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 ToAsyncDisk for CompositeDiskFile
impl ToAsyncDisk for CompositeDiskFile
source§fn to_async_disk(self: Box<Self>, ex: &Executor) -> Result<Box<dyn AsyncDisk>>
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§
impl !RefUnwindSafe for CompositeDiskFile
impl Send for CompositeDiskFile
impl !Sync for CompositeDiskFile
impl Unpin for CompositeDiskFile
impl !UnwindSafe for CompositeDiskFile
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more