Trait ArtifactStorage

Source
pub trait ArtifactStorage {
    // Required methods
    fn load_artifact(
        &mut self,
        loader_info: &dyn LoaderInfoProvider,
        artifact_type_id: &ArtifactTypeId,
        artifact_id: ArtifactId,
        data: Vec<u8>,
        load_handle: LoadHandle,
        load_op: ArtifactLoadOp,
    ) -> Result<(), Box<dyn Error + Send + 'static>>;
    fn commit_artifact(
        &mut self,
        artifact_type: ArtifactTypeId,
        load_handle: LoadHandle,
    );
    fn free_artifact(
        &mut self,
        artifact_type_id: ArtifactTypeId,
        load_handle: LoadHandle,
    );
}
Expand description

Storage for all artifacts of all artifact types.

Consumers are expected to provide the implementation for this, as this is the bridge between Loader and the application.

Required Methods§

Source

fn load_artifact( &mut self, loader_info: &dyn LoaderInfoProvider, artifact_type_id: &ArtifactTypeId, artifact_id: ArtifactId, data: Vec<u8>, load_handle: LoadHandle, load_op: ArtifactLoadOp, ) -> Result<(), Box<dyn Error + Send + 'static>>

Updates the backing data of an artifact.

An example usage of this is when a texture such as “player.png” changes while the application is running. The artifact ID is the same, but the underlying pixel data can differ.

§Parameters
  • loader: Loader implementation calling this function.
  • artifact_type_id: UUID of the artifact type.
  • data: The updated artifact byte data.
  • load_handle: ID allocated by Loader to track loading of a particular artifact.
  • load_op: Allows the loading implementation to signal when loading is done / errors.
Source

fn commit_artifact( &mut self, artifact_type: ArtifactTypeId, load_handle: LoadHandle, )

Commits the specified artifact as loaded and ready to use.

§Parameters
  • artifact_type: UUID of the artifact type.
  • load_handle: ID allocated by Loader to track loading of a particular artifact.
Source

fn free_artifact( &mut self, artifact_type_id: ArtifactTypeId, load_handle: LoadHandle, )

Frees the artifact identified by the load handle.

§Parameters
  • artifact_type_id: UUID of the artifact type.
  • load_handle: ID allocated by Loader to track loading of a particular artifact.

Implementors§