pub trait Create<B: Backend> {
// Required methods
fn settings(&self) -> B::Settings;
fn build(self, header: [u8; 512], overwrite: bool) -> Result<B, B::Err>;
}
Expand description
Trait to configure the creation of a Backend
.
Should contain options used to create a specific backend. When a container is created, this trait is used to create the related backend.
The Create::settings()
method returns an instance of the settings of
this backend instance. The settings contains runtime configuration used by
the backend. The container stores the settings (possibly encrypted) in the
header of the container and should contain all settings/information needed
by the backend. It is loaded again from the header when the container is
opened.
Finally, the container calls Create::build()
to create an instance of the
Backend
. The resulting backend instance should be able to handle all
operations on it. The Create::build()
method should validate all its
settings before returning the backend instance!
Required Methods§
Sourcefn settings(&self) -> B::Settings
fn settings(&self) -> B::Settings
Returns the settings of this backend instance.
The settings contains runtime configuration used by the backend. The container stores the settings (possibly encrypted) in the header of the container and should contain all settings/information needed by the backend. It is loaded again from the header when the container is opened.
Sourcefn build(self, header: [u8; 512], overwrite: bool) -> Result<B, B::Err>
fn build(self, header: [u8; 512], overwrite: bool) -> Result<B, B::Err>
Create an instance of the Backend
.
The container calls Create::build()
to create an instance of the
Backend
. The resulting backend instance should be able to handle
all operations on it. The Create::build()
method should validate
all its settings before returning the backend instance!
The header
argument contains the binary data of the (possibly
encrypted) header of the container. The method should persist the
header in the backend.
If overwrite
is true
, then an existing backend instance should be
overwritten. If overwrite
is set to false
and the requested backend
instance exists, the build should fail.