pub struct Qcow2OpenBuilder<S: Storage + 'static, F: WrappedFormat<S> + 'static = FormatAccess<S>> {
base: FormatDriverBuilderBase<S>,
backing: Option<Option<FormatOrBuilder<S, F>>>,
data_file: Option<Option<StorageOrPath<S>>>,
}
Expand description
Options builder for opening a qcow2 image.
Allows setting various options one by one to open a qcow2 image.
Fields§
§base: FormatDriverBuilderBase<S>
Basic options.
backing: Option<Option<FormatOrBuilder<S, F>>>
Backing image
None
to open the image as specified by the image header, Some(None)
to not open any
backing image, and Some(Some(_))
to use that backing image.
data_file: Option<Option<StorageOrPath<S>>>
External data file
None
to open the file as specified by the image header, Some(None)
to not open any data
file, and Some(Some(_))
to use that data file.
Implementations§
Source§impl<S: Storage + 'static, F: WrappedFormat<S> + 'static> Qcow2OpenBuilder<S, F>
impl<S: Storage + 'static, F: WrappedFormat<S> + 'static> Qcow2OpenBuilder<S, F>
Sourcefn with_base(base: FormatDriverBuilderBase<S>) -> Self
fn with_base(base: FormatDriverBuilderBase<S>) -> Self
Create a new instance.
Sourcepub fn backing(self, backing: Option<F>) -> Self
pub fn backing(self, backing: Option<F>) -> Self
Set a backing image.
This overrides the implicit backing image given in the image header. Passing None
means
not to use any backing image (regardless of whether the image header defines a backing
image).
Sourcepub fn backing_path<P: AsRef<Path>>(self, backing: P, format: Format) -> Self
pub fn backing_path<P: AsRef<Path>>(self, backing: P, format: Format) -> Self
Declare a backing image by path.
Let imago open the given path as an image with the given format.
Use with caution, as the given image will be opened with default options.
Qcow2OpenBuilder::backing()
is preferable, as it allows you control over how the
backing image is opened.
Sourcepub fn data_file(self, data_file: Option<S>) -> Self
pub fn data_file(self, data_file: Option<S>) -> Self
Set an external data file.
This overrides the implicit external data file given in the image header. Passing None
means not to use any external data file (regardless of whether the image header defines an
external data file, and regardless of whether the image header says the image has an
external data file).
Similarly, passing a data file will then always use that data file, regardless of whether the image header says the image has an external data file.
Note that it is wrong to set a data file for an image that does not have one, and it is wrong to enforce not using a data file for an image that has one. There is no way to know whether the image needs an external data file until it is opened.
If you want to open a specific data file if and only if the image needs it, call
Qcow2OpenBuilder::data_file(None)
to prevent any data file from being automatically
opened; open the image, then check Qcow2::requires_external_data_file()
, and, if true,
invoke Qcow2::set_data_file()
.
Trait Implementations§
Source§impl<S: Storage + 'static, F: WrappedFormat<S> + 'static> FormatDriverBuilder<S> for Qcow2OpenBuilder<S, F>
impl<S: Storage + 'static, F: WrappedFormat<S> + 'static> FormatDriverBuilder<S> for Qcow2OpenBuilder<S, F>
Source§fn storage_open_options(self, options: StorageOpenOptions) -> Self
fn storage_open_options(self, options: StorageOpenOptions) -> Self
Source§async fn open<G: ImplicitOpenGate<S>>(self, gate: G) -> Result<Self::Format>
async fn open<G: ImplicitOpenGate<S>>(self, gate: G) -> Result<Self::Format>
Source§fn get_image_path(&self) -> Option<PathBuf>
fn get_image_path(&self) -> Option<PathBuf>
Source§fn get_writable(&self) -> bool
fn get_writable(&self) -> bool
Source§fn get_storage_open_options(&self) -> Option<&StorageOpenOptions>
fn get_storage_open_options(&self) -> Option<&StorageOpenOptions>
Source§fn open_sync<G: ImplicitOpenGate<S>>(self, gate: G) -> Result<Self::Format>
fn open_sync<G: ImplicitOpenGate<S>>(self, gate: G) -> Result<Self::Format>
FormatDriverBuilder::open()
. Read more