Trait ImplicitOpenGate

Source
pub trait ImplicitOpenGate<S: Storage>: Default {
    // Required methods
    async fn open_format<F: FormatDriverBuilder<S>>(
        &mut self,
        builder: F,
    ) -> Result<F::Format>;
    async fn open_storage(&mut self, builder: StorageOpenOptions) -> Result<S>;
}
Expand description

Gate implicit image and storage object dependencies.

Depending on their format, images may have external image and storage object dependencies; for example, qcow2 images can reference a backing image (any image format), and an external data file (pure storage object, no format). You can override these implicit choices when opening images, but if you do not, they are carried out automatically.

However, opening implicit dependencies is always done through an object of type ImplicitOpenGate, which you pass to FormatDriverBuilder::open(). Implementing this trait therefore allows you to restrict if and how images an storage objects are opened implicitly.

Anytime a storage object is opened, it is done by an ImplicitOpenGate::open_storage() implementation. Anytime a format layer is opened, it is done by an ImplicitOpenGate::open_format() implementation. Therefore, unless your implementation does perform this open operation, nothing will be opened.

Do note however that whatever you open explicitly through FormatDriverBuilder::open() or Storage::open() is not run through ImplicitOpenGate.

See PermissiveImplicitOpenGate and DenyImplicitOpenGate.

Required Methods§

Source

async fn open_format<F: FormatDriverBuilder<S>>( &mut self, builder: F, ) -> Result<F::Format>

Open an implicitly referenced format layer.

You can e.g. check the supposed format via F::FORMAT, and its filename via builder.get_image_path().

Note that this is not invoked for images that are explicitly opened, i.e. whenever FormatDriverBuilder::open() is called by imago users.

Source

async fn open_storage(&mut self, builder: StorageOpenOptions) -> Result<S>

Open an implicitly referenced storage object.

You can e.g. check the filename via builder.get_filename().

Note that this is not invoked for storage objects that are explicitly opened, i.e. whenever an object of type S is created by imago users (e.g. via S::open()).

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.

Implementors§