Trait bevy::asset::processor::Process

source ·
pub trait Process: Send + Sync + Sized + 'static {
    type Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>;
    type OutputLoader: AssetLoader;

    // Required method
    fn process<'a>(
        &'a self,
        context: &'a mut ProcessContext<'_>,
        meta: AssetMeta<(), Self>,
        writer: &'a mut (dyn AsyncWrite + Send + Sync + Unpin + 'static)
    ) -> Pin<Box<dyn Future<Output = Result<<Self::OutputLoader as AssetLoader>::Settings, ProcessError>> + Send + 'a>>;
}
Expand description

Asset “processor” logic that reads input asset bytes (stored on ProcessContext), processes the value in some way, and then writes the final processed bytes with Writer. The resulting bytes must be loadable with the given Process::OutputLoader.

This is a “low level”, maximally flexible interface. Most use cases are better served by the LoadTransformAndSave implementation of Process.

Required Associated Types§

source

type Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>

The configuration / settings used to process the asset. This will be stored in the AssetMeta and is user-configurable per-asset.

source

type OutputLoader: AssetLoader

The AssetLoader that will be used to load the final processed asset.

Required Methods§

source

fn process<'a>( &'a self, context: &'a mut ProcessContext<'_>, meta: AssetMeta<(), Self>, writer: &'a mut (dyn AsyncWrite + Send + Sync + Unpin + 'static) ) -> Pin<Box<dyn Future<Output = Result<<Self::OutputLoader as AssetLoader>::Settings, ProcessError>> + Send + 'a>>

Processes the asset stored on context in some way using the settings stored on meta. The results are written to writer. The final written processed asset is loadable using Process::OutputLoader. This load will use the returned AssetLoader::Settings.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Process for ()

The () processor should never be called. This implementation exists to make the meta format nicer to work with.

§

type Settings = ()

§

type OutputLoader = ()

source§

fn process<'a>( &'a self, _context: &'a mut ProcessContext<'_>, _meta: AssetMeta<(), ()>, _writer: &'a mut (dyn AsyncWrite + Send + Sync + Unpin + 'static) ) -> Pin<Box<dyn Future<Output = Result<(), ProcessError>> + Send + 'a>>

Implementors§

source§

impl<Loader, Saver> Process for LoadAndSave<Loader, Saver>
where Loader: AssetLoader, Saver: AssetSaver<Asset = <Loader as AssetLoader>::Asset>,

source§

impl<Loader, T, Saver> Process for LoadTransformAndSave<Loader, T, Saver>
where Loader: AssetLoader, T: AssetTransformer<AssetInput = <Loader as AssetLoader>::Asset>, Saver: AssetSaver<Asset = <T as AssetTransformer>::AssetOutput>,