Trait libre_pvz_resources::loader::TwoStageAsset

source ·
pub trait TwoStageAsset: Asset + Sized {
    type Repr: Decode + DeserializeOwned;

    const EXTENSIONS: AssetExtensions;

    // Required method
    fn post_process(
        repr: Self::Repr,
        load_context: &mut LoadContext<'_>
    ) -> Result<(Self, Vec<AssetPath<'static>>)>;
}
Expand description

A new trait for two-stage asset loading, in place of AssetLoader:

  • Decode from bincode/JSON/YAML etc. to get structural data
  • Post-processing the structural data, transforming & adding dependencies This is meant to support loading the same data structures stored in different serialised forms, and share their post-processing logic.

Required Associated Types§

source

type Repr: Decode + DeserializeOwned

The decoded representation for this asset.

Required Associated Constants§

source

const EXTENSIONS: AssetExtensions

The file extensions this asset is associated to.

Required Methods§

source

fn post_process( repr: Self::Repr, load_context: &mut LoadContext<'_> ) -> Result<(Self, Vec<AssetPath<'static>>)>

The post-processing logic: transform the Repr to a more compact in-memory form, require loading the dependencies and store their handles in the appropriate locations, and submit the resulting asset to the asset loader.

Object Safety§

This trait is not object safe.

Implementors§