Trait DynStorage

Source
pub trait DynStorage:
    Any
    + Debug
    + Display
    + Send
    + Sync {
Show 16 methods // Required methods fn dyn_mem_align(&self) -> usize; fn dyn_req_align(&self) -> usize; fn dyn_zero_align(&self) -> usize; fn dyn_discard_align(&self) -> usize; fn dyn_size(&self) -> Result<u64>; fn dyn_resolve_relative_path(&self, relative: &Path) -> Result<PathBuf>; fn dyn_get_filename(&self) -> Option<PathBuf>; unsafe fn dyn_pure_readv<'a>( &'a self, bufv: IoVectorMut<'a>, offset: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>>; unsafe fn dyn_pure_writev<'a>( &'a self, bufv: IoVector<'a>, offset: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>>; unsafe fn dyn_pure_write_zeroes( &self, offset: u64, length: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>; unsafe fn dyn_pure_discard( &self, offset: u64, length: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>; fn dyn_flush(&self) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>; fn dyn_sync(&self) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>; unsafe fn dyn_invalidate_cache( &self, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>; fn dyn_get_storage_helper(&self) -> &CommonStorageHelper; fn dyn_resize( &self, new_size: u64, prealloc_mode: PreallocateMode, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>;
}
Expand description

Allow dynamic use of storage objects (i.e. is object safe).

When using normal Storage objects, they must all be of the same type within a single disk image chain. For example, every storage object underneath a FormatAccess<StdFile> object must be of type StdFile.

DynStorage allows the use of Box<dyn DynStorage>, which implements Storage, to allow mixed storage object types. Therefore, a FormatAccess<Box<dyn DynStorage>> allows e.g. the use of both Box<StdFile> and Box<Null> storage objects together. (Arc instead of Box works, too.)

Async functions in DynStorage return boxed futures (Pin<Box<dyn Future>>), which makes them slighly less efficient than async functions in Storage, hence the distinction.

Required Methods§

Source

fn dyn_mem_align(&self) -> usize

Wrapper around Storage::mem_align().

Source

fn dyn_req_align(&self) -> usize

Wrapper around Storage::req_align().

Source

fn dyn_zero_align(&self) -> usize

Wrapper around Storage::zero_align().

Source

fn dyn_discard_align(&self) -> usize

Wrapper around Storage::discard_align().

Source

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

Wrapper around Storage::size().

Source

fn dyn_resolve_relative_path(&self, relative: &Path) -> Result<PathBuf>

Source

fn dyn_get_filename(&self) -> Option<PathBuf>

Wrapper around Storage::get_filename()

Source

unsafe fn dyn_pure_readv<'a>( &'a self, bufv: IoVectorMut<'a>, offset: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>>

Object-safe wrapper around Storage::pure_readv().

§Safety

Same considerations are for Storage::pure_readv() apply.

Source

unsafe fn dyn_pure_writev<'a>( &'a self, bufv: IoVector<'a>, offset: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>>

Object-safe wrapper around Storage::pure_writev().

§Safety

Same considerations are for Storage::pure_writev() apply.

Source

unsafe fn dyn_pure_write_zeroes( &self, offset: u64, length: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>

Object-safe wrapper around Storage::pure_write_zeroes().

§Safety

Same considerations are for Storage::pure_write_zeroes() apply.

Source

unsafe fn dyn_pure_discard( &self, offset: u64, length: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>

Object-safe wrapper around Storage::pure_discard().

§Safety

Same considerations are for Storage::pure_discard() apply.

Source

fn dyn_flush(&self) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>

Object-safe wrapper around Storage::flush().

Source

fn dyn_sync(&self) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>

Object-safe wrapper around Storage::sync().

Source

unsafe fn dyn_invalidate_cache( &self, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>

Object-safe wrapper around Storage::invalidate_cache().

§Safety

Same considerations are for Storage::invalidate_cache() apply.

Source

fn dyn_get_storage_helper(&self) -> &CommonStorageHelper

Source

fn dyn_resize( &self, new_size: u64, prealloc_mode: PreallocateMode, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>

Wrapper around Storage::resize().

Trait Implementations§

Source§

impl Storage for Box<dyn DynStorage>

Source§

async fn open(opts: StorageOpenOptions) -> Result<Self>

Open a storage object. Read more
Source§

async fn create_open(opts: StorageCreateOptions) -> Result<Self>

Create a storage object and open it. Read more
Source§

fn mem_align(&self) -> usize

Minimum required alignment for memory buffers.
Source§

fn req_align(&self) -> usize

Minimum required alignment for offsets and lengths.
Source§

fn zero_align(&self) -> usize

Minimum required alignment for zero writes.
Source§

fn discard_align(&self) -> usize

Minimum required alignment for effective discards.
Source§

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

Storage object length.
Source§

fn resolve_relative_path<P: AsRef<Path>>(&self, relative: P) -> Result<PathBuf>

Resolve the given path relative to this storage object. Read more
Source§

fn get_filename(&self) -> Option<PathBuf>

Return a filename, if possible. Read more
Source§

async unsafe fn pure_readv( &self, bufv: IoVectorMut<'_>, offset: u64, ) -> Result<()>

Read data at offset into bufv. Read more
Source§

async unsafe fn pure_writev( &self, bufv: IoVector<'_>, offset: u64, ) -> Result<()>

Write data from bufv to offset. Read more
Source§

async unsafe fn pure_write_zeroes(&self, offset: u64, length: u64) -> Result<()>

Ensure the given range reads back as zeroes. Read more
Source§

async unsafe fn pure_discard(&self, offset: u64, length: u64) -> Result<()>

Discard the given range, with undefined contents when read back. Read more
Source§

async fn flush(&self) -> Result<()>

Flush internal buffers. Read more
Source§

async fn sync(&self) -> Result<()>

Sync data already written to the storage hardware. Read more
Source§

async unsafe fn invalidate_cache(&self) -> Result<()>

Drop internal buffers. Read more
Source§

fn get_storage_helper(&self) -> &CommonStorageHelper

Return the storage helper object (used by the StorageExt implementation).
Source§

async fn resize( &self, new_size: u64, prealloc_mode: PreallocateMode, ) -> Result<()>

Resize to the given size. Read more
Source§

fn open_sync(opts: StorageOpenOptions) -> Result<Self>

Synchronous wrapper around Storage::open().
Source§

async fn create(opts: StorageCreateOptions) -> Result<()>

Create a storage object. Read more

Implementors§

Source§

impl<S: Storage + 'static> DynStorage for S