pub struct Raw<S: Storage + 'static> {
inner: S,
writable: bool,
size: AtomicU64,
resize_lock: Mutex<u64>,
}Expand description
Wraps a storage object without any translation.
Fields§
§inner: SWrapped storage object.
writable: boolWhether this image may be modified.
size: AtomicU64Disk size, which is the file size when this object was created.
Copy of the value in resize_lock, for lock-free reading. Must only be changed via
Raw::set_size().
resize_lock: Mutex<u64>Disk size, for resize operations.
Every resize path (growing and shrinking) must hold this lock throughout, and change the
size only via Raw::set_size(). This serializes resizes, so a resize to a smaller size
cannot overtake one to a larger size and shrink the storage below the image size.
Implementations§
Source§impl<S: Storage + 'static> Raw<S>
impl<S: Storage + 'static> Raw<S>
Sourcepub fn builder(image: S) -> RawOpenBuilder<S>
pub fn builder(image: S) -> RawOpenBuilder<S>
Create a new FormatDriverBuilder instance for the given image.
Sourcepub fn builder_path<P: AsRef<Path>>(image_path: P) -> RawOpenBuilder<S>
pub fn builder_path<P: AsRef<Path>>(image_path: P) -> RawOpenBuilder<S>
Create a new FormatDriverBuilder instance for an image under the given path.
Sourcepub fn create_builder(image: S) -> RawCreateBuilder<S>
pub fn create_builder(image: S) -> RawCreateBuilder<S>
Create a new FormatCreateBuilder instance for the given file.
Sourcepub async fn open_image(inner: S, writable: bool) -> Result<Self>
pub async fn open_image(inner: S, writable: bool) -> Result<Self>
Wrap inner, allowing it to be used as a disk image in raw format.
Sourcepub async fn open_path<P: AsRef<Path>>(path: P, writable: bool) -> Result<Self>
pub async fn open_path<P: AsRef<Path>>(path: P, writable: bool) -> Result<Self>
Open the given path as a storage object, and wrap it in Raw.
Sourcepub fn open_image_sync(inner: S, writable: bool) -> Result<Self>
pub fn open_image_sync(inner: S, writable: bool) -> Result<Self>
Wrap inner, allowing it to be used as a disk image in raw format.
Sourcepub fn open_path_sync<P: AsRef<Path>>(path: P, writable: bool) -> Result<Self>
pub fn open_path_sync<P: AsRef<Path>>(path: P, writable: bool) -> Result<Self>
Synchronous wrapper around Raw::open_path().
Sourcefn set_size(&self, size_guard: &mut MutexGuard<'_, u64>, new_size: u64)
fn set_size(&self, size_guard: &mut MutexGuard<'_, u64>, new_size: u64)
Set the disk size.
Requires the guard of resize_lock, which must be held throughout the whole resize
operation.
Trait Implementations§
Source§impl<S: Storage + 'static> FormatDriverInstance for Raw<S>
impl<S: Storage + 'static> FormatDriverInstance for Raw<S>
Source§unsafe fn probe<'life0, 'async_trait>(
_storage: &'life0 S,
) -> Pin<Box<dyn Future<Output = Result<bool>> + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
unsafe fn probe<'life0, 'async_trait>(
_storage: &'life0 S,
) -> Pin<Box<dyn Future<Output = Result<bool>> + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
storage has this format. Read moreSource§fn zero_granularity(&self) -> Option<u64>
fn zero_granularity(&self) -> Option<u64>
Source§fn collect_storage_dependencies(&self) -> Vec<&S>
fn collect_storage_dependencies(&self) -> Vec<&S>
Source§fn get_mapping<'a, 'async_trait>(
&'a self,
offset: u64,
max_length: u64,
) -> Pin<Box<dyn Future<Output = Result<(ShallowMapping<'a, S>, u64)>> + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn get_mapping<'a, 'async_trait>(
&'a self,
offset: u64,
max_length: u64,
) -> Pin<Box<dyn Future<Output = Result<(ShallowMapping<'a, S>, u64)>> + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
offset. Read moreSource§fn ensure_data_mapping<'a, 'async_trait>(
&'a self,
offset: u64,
length: u64,
_overwrite: bool,
) -> Pin<Box<dyn Future<Output = Result<(&'a S, u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn ensure_data_mapping<'a, 'async_trait>(
&'a self,
offset: u64,
length: u64,
_overwrite: bool,
) -> Pin<Box<dyn Future<Output = Result<(&'a S, u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Source§fn ensure_zero_mapping<'life0, 'async_trait>(
&'life0 self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ensure_zero_mapping<'life0, 'async_trait>(
&'life0 self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§unsafe fn discard_to_zero_unsafe<'life0, 'async_trait>(
&'life0 self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
unsafe fn discard_to_zero_unsafe<'life0, 'async_trait>(
&'life0 self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§unsafe fn discard_to_any_unsafe<'life0, 'async_trait>(
&'life0 self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
unsafe fn discard_to_any_unsafe<'life0, 'async_trait>(
&'life0 self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§unsafe fn discard_to_backing_unsafe<'life0, 'async_trait>(
&'life0 self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
unsafe fn discard_to_backing_unsafe<'life0, 'async_trait>(
&'life0 self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn sync<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn sync<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§unsafe fn invalidate_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
unsafe fn invalidate_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn resize_grow<'life0, 'async_trait>(
&'life0 self,
new_size: u64,
format_prealloc_mode: PreallocateMode,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn resize_grow<'life0, 'async_trait>(
&'life0 self,
new_size: u64,
format_prealloc_mode: PreallocateMode,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn resize_shrink<'life0, 'async_trait>(
&'life0 mut self,
new_size: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn resize_shrink<'life0, 'async_trait>(
&'life0 mut self,
new_size: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn prepare_data_mapping<'a, 'async_trait>(
&'a self,
offset: u64,
length: u64,
overwrite: bool,
) -> Pin<Box<dyn Future<Output = Result<PreparedDataMapping<'a, Self::Storage>>> + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn prepare_data_mapping<'a, 'async_trait>(
&'a self,
offset: u64,
length: u64,
overwrite: bool,
) -> Pin<Box<dyn Future<Output = Result<PreparedDataMapping<'a, Self::Storage>>> + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
offset. Read moreSource§fn commit_data_mapping<'life0, 'life1, 'async_trait>(
&'life0 self,
mapping: PreparedDataMapping<'life1, Self::Storage>,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn commit_data_mapping<'life0, 'life1, 'async_trait>(
&'life0 self,
mapping: PreparedDataMapping<'life1, Self::Storage>,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
FormatDriverInstance::prepare_data_mapping() visible. Read moreSource§fn discard_to_zero<'life0, 'async_trait>(
&'life0 mut self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn discard_to_zero<'life0, 'async_trait>(
&'life0 mut self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn discard_to_any<'life0, 'async_trait>(
&'life0 mut self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn discard_to_any<'life0, 'async_trait>(
&'life0 mut self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn discard_to_backing<'life0, 'async_trait>(
&'life0 mut self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn discard_to_backing<'life0, 'async_trait>(
&'life0 mut self,
offset: u64,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<(u64, u64)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn readv_special<'life0, 'life1, 'async_trait>(
&'life0 self,
_bufv: IoVectorMut<'life1>,
_offset: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn readv_special<'life0, 'life1, 'async_trait>(
&'life0 self,
_bufv: IoVectorMut<'life1>,
_offset: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
ShallowMapping::Special area.Source§fn try_readv_special<'a, 'life0, 'async_trait>(
&'life0 self,
bufv: IoVectorMut<'a>,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<(IoVectorMut<'a>, u64)>>> + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn try_readv_special<'a, 'life0, 'async_trait>(
&'life0 self,
bufv: IoVectorMut<'a>,
offset: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<(IoVectorMut<'a>, u64)>>> + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
ShallowMapping::Special area, returning the unhandled tail. Read more