pub trait DynStorage:
Any
+ Debug
+ Display
+ Send
+ Sync {
Show 17 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_write_allocated_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.)
In async mode, async functions in DynStorage return boxed futures (Pin<Box<dyn Future>>),
which makes them slightly less efficient than async functions in Storage, hence the
distinction. In sync mode, they return values directly, so there would be no need for this
distinct trait, but we keep it for compatibility between sync and async.
Required Methods§
Sourcefn dyn_mem_align(&self) -> usize
fn dyn_mem_align(&self) -> usize
Wrapper around Storage::mem_align().
Sourcefn dyn_req_align(&self) -> usize
fn dyn_req_align(&self) -> usize
Wrapper around Storage::req_align().
Sourcefn dyn_zero_align(&self) -> usize
fn dyn_zero_align(&self) -> usize
Wrapper around Storage::zero_align().
Sourcefn dyn_discard_align(&self) -> usize
fn dyn_discard_align(&self) -> usize
Wrapper around Storage::discard_align().
Sourcefn dyn_size(&self) -> Result<u64>
fn dyn_size(&self) -> Result<u64>
Wrapper around Storage::size().
Sourcefn dyn_resolve_relative_path(&self, relative: &Path) -> Result<PathBuf>
fn dyn_resolve_relative_path(&self, relative: &Path) -> Result<PathBuf>
Wrapper around Storage::resolve_relative_path().
Sourcefn dyn_get_filename(&self) -> Option<PathBuf>
fn dyn_get_filename(&self) -> Option<PathBuf>
Wrapper around Storage::get_filename()
Sourceunsafe fn dyn_pure_readv<'a>(
&'a self,
bufv: IoVectorMut<'a>,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>>
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 as for Storage::pure_readv() apply.
Sourceunsafe fn dyn_pure_writev<'a>(
&'a self,
bufv: IoVector<'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>>
Object-safe wrapper around Storage::pure_writev().
§Safety
Same considerations as for Storage::pure_writev() apply.
Sourceunsafe fn dyn_pure_write_zeroes(
&self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
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 as for Storage::pure_write_zeroes() apply.
Sourceunsafe fn dyn_pure_write_allocated_zeroes(
&self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
unsafe fn dyn_pure_write_allocated_zeroes( &self, offset: u64, length: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
Object-safe wrapper around Storage::pure_write_allocated_zeroes().
§Safety
Same considerations as for Storage::pure_write_allocated_zeroes() apply.
Sourceunsafe fn dyn_pure_discard(
&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<()>> + '_>>
Object-safe wrapper around Storage::pure_discard().
§Safety
Same considerations as for Storage::pure_discard() apply.
Sourcefn dyn_flush(&self) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
fn dyn_flush(&self) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
Object-safe wrapper around Storage::flush().
Sourcefn dyn_sync(&self) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
fn dyn_sync(&self) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
Object-safe wrapper around Storage::sync().
Sourceunsafe fn dyn_invalidate_cache(
&self,
) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
unsafe fn dyn_invalidate_cache( &self, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
Object-safe wrapper around Storage::invalidate_cache().
§Safety
Same considerations as for Storage::invalidate_cache() apply.
Sourcefn dyn_get_storage_helper(&self) -> &CommonStorageHelper
fn dyn_get_storage_helper(&self) -> &CommonStorageHelper
Wrapper around Storage::get_storage_helper().
Sourcefn dyn_resize(
&self,
new_size: u64,
prealloc_mode: PreallocateMode,
) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
fn dyn_resize( &self, new_size: u64, prealloc_mode: PreallocateMode, ) -> Pin<Box<dyn Future<Output = Result<()>> + '_>>
Object-safe wrapper around Storage::resize().
Trait Implementations§
Source§impl Storage for Box<dyn DynStorage>
impl Storage for Box<dyn DynStorage>
Source§async fn create_open(opts: StorageCreateOptions) -> Result<Self>
async fn create_open(opts: StorageCreateOptions) -> Result<Self>
Source§fn zero_align(&self) -> usize
fn zero_align(&self) -> usize
Source§fn discard_align(&self) -> usize
fn discard_align(&self) -> usize
Source§fn resolve_relative_path<P: AsRef<Path>>(&self, relative: P) -> Result<PathBuf>
fn resolve_relative_path<P: AsRef<Path>>(&self, relative: P) -> Result<PathBuf>
Source§async unsafe fn pure_readv(
&self,
bufv: IoVectorMut<'_>,
offset: u64,
) -> Result<()>
async unsafe fn pure_readv( &self, bufv: IoVectorMut<'_>, offset: u64, ) -> Result<()>
Source§async unsafe fn pure_write_zeroes(&self, offset: u64, length: u64) -> Result<()>
async unsafe fn pure_write_zeroes(&self, offset: u64, length: u64) -> Result<()>
Source§async unsafe fn pure_write_allocated_zeroes(
&self,
offset: u64,
length: u64,
) -> Result<()>
async unsafe fn pure_write_allocated_zeroes( &self, offset: u64, length: u64, ) -> Result<()>
Source§async unsafe fn pure_discard(&self, offset: u64, length: u64) -> Result<()>
async unsafe fn pure_discard(&self, offset: u64, length: u64) -> Result<()>
Source§async fn sync(&self) -> Result<()>
async fn sync(&self) -> Result<()>
Source§fn get_storage_helper(&self) -> &CommonStorageHelper
fn get_storage_helper(&self) -> &CommonStorageHelper
StorageExt
implementation).Source§async fn resize(
&self,
new_size: u64,
prealloc_mode: PreallocateMode,
) -> Result<()>
async fn resize( &self, new_size: u64, prealloc_mode: PreallocateMode, ) -> Result<()>
Source§fn open_sync(opts: StorageOpenOptions) -> Result<Self>
fn open_sync(opts: StorageOpenOptions) -> Result<Self>
Storage::open().