pub trait FormatCreateBuilder<S: Storage>: Sized {
type DriverBuilder: FormatDriverBuilder<S>;
const FORMAT: Format;
// Required methods
fn new(image: S) -> Self;
fn size(self, size: u64) -> Self;
fn preallocate(self, prealloc_mode: PreallocateMode) -> Self;
async fn create(self) -> Result<()>;
async fn create_open<G: ImplicitOpenGate<S>, F: FnOnce(S) -> Result<Self::DriverBuilder>>(
self,
open_gate: G,
open_builder_fn: F,
) -> Result<<Self::DriverBuilder as FormatDriverBuilder<S>>::Format>;
fn get_size(&self) -> u64;
fn get_preallocate(&self) -> PreallocateMode;
}
Expand description
Prepares creating (formatting) an image.
There are common options for all kinds of formats, which are accessible through this trait’s methods, but there are also specialized options that depend on the format itself. Each implementation will provide such specialized methods.
See Qcow2CreateBuilder
for an example implementation.
Required Associated Constants§
Required Associated Types§
Sourcetype DriverBuilder: FormatDriverBuilder<S>
type DriverBuilder: FormatDriverBuilder<S>
Open builder type for this format.
Required Methods§
Sourcefn preallocate(self, prealloc_mode: PreallocateMode) -> Self
fn preallocate(self, prealloc_mode: PreallocateMode) -> Self
Set the desired preallocation mode.
Sourceasync fn create(self) -> Result<()>
async fn create(self) -> Result<()>
Format the image file.
Formats the underlying image file according to the options specified in self
.
This will delete any currently present data in the image!
Sourceasync fn create_open<G: ImplicitOpenGate<S>, F: FnOnce(S) -> Result<Self::DriverBuilder>>(
self,
open_gate: G,
open_builder_fn: F,
) -> Result<<Self::DriverBuilder as FormatDriverBuilder<S>>::Format>
async fn create_open<G: ImplicitOpenGate<S>, F: FnOnce(S) -> Result<Self::DriverBuilder>>( self, open_gate: G, open_builder_fn: F, ) -> Result<<Self::DriverBuilder as FormatDriverBuilder<S>>::Format>
Format the image file and open it.
Same as FormatCreateBuilder::create()
, but also opens the image file.
Note that the image file will always be opened as writable, regardless of whether this was
set in open_builder
or not. This is because formatting requires the image to be
writable.
Sourcefn get_preallocate(&self) -> PreallocateMode
fn get_preallocate(&self) -> PreallocateMode
Get the preallocation mode.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.