Struct Qcow2OpenBuilder

Source
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>

Source

fn with_base(base: FormatDriverBuilderBase<S>) -> Self

Create a new instance.

Source

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).

Source

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.

Source

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>

Source§

const FORMAT: Format = Format::Qcow2

Which format this is.
Source§

type Format = Qcow2<S, F>

The format object that this builder will create.
Source§

fn new(image: S) -> Self

Prepare opening the given image.
Source§

fn new_path<P: AsRef<Path>>(path: P) -> Self

Prepare opening an image under the given path.
Source§

fn write(self, write: bool) -> Self

Whether the image should be writable or not.
Source§

fn storage_open_options(self, options: StorageOpenOptions) -> Self

Set base storage options for opened storage objects. Read more
Source§

async fn open<G: ImplicitOpenGate<S>>(self, gate: G) -> Result<Self::Format>

Open the image. Read more
Source§

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

If possible, get the image’s path.
Source§

fn get_writable(&self) -> bool

Return the set writable state.
Source§

fn get_storage_open_options(&self) -> Option<&StorageOpenOptions>

Return the set storage options (if any).
Source§

fn open_sync<G: ImplicitOpenGate<S>>(self, gate: G) -> Result<Self::Format>

Synchronous wrapper around FormatDriverBuilder::open(). Read more

Auto Trait Implementations§

§

impl<S, F> Freeze for Qcow2OpenBuilder<S, F>
where S: Freeze, F: Freeze,

§

impl<S, F = FormatAccess<S>> !RefUnwindSafe for Qcow2OpenBuilder<S, F>

§

impl<S, F> Send for Qcow2OpenBuilder<S, F>

§

impl<S, F> Sync for Qcow2OpenBuilder<S, F>

§

impl<S, F> Unpin for Qcow2OpenBuilder<S, F>
where S: Unpin, F: Unpin,

§

impl<S, F = FormatAccess<S>> !UnwindSafe for Qcow2OpenBuilder<S, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more