bevy_asset::transformer

Trait AssetTransformer

Source
pub trait AssetTransformer:
    Send
    + Sync
    + 'static {
    type AssetInput: Asset;
    type AssetOutput: Asset;
    type Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>;
    type Error: Into<Box<dyn Error + Send + Sync + 'static>>;

    // Required method
    fn transform<'a>(
        &'a self,
        asset: TransformedAsset<Self::AssetInput>,
        settings: &'a Self::Settings,
    ) -> impl ConditionalSendFuture<Output = Result<TransformedAsset<Self::AssetOutput>, Self::Error>>;
}
Expand description

Transforms an Asset of a given AssetTransformer::AssetInput type to an Asset of AssetTransformer::AssetOutput type.

This trait is commonly used in association with LoadTransformAndSave to accomplish common asset pipeline workflows.

Required Associated Types§

Source

type AssetInput: Asset

The Asset type which this AssetTransformer takes as and input.

Source

type AssetOutput: Asset

The Asset type which this AssetTransformer outputs.

Source

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

The settings type used by this AssetTransformer.

Source

type Error: Into<Box<dyn Error + Send + Sync + 'static>>

The type of error which could be encountered by this transformer.

Required Methods§

Source

fn transform<'a>( &'a self, asset: TransformedAsset<Self::AssetInput>, settings: &'a Self::Settings, ) -> impl ConditionalSendFuture<Output = Result<TransformedAsset<Self::AssetOutput>, Self::Error>>

Transforms the given TransformedAsset to AssetTransformer::AssetOutput. The TransformedAsset’s labeled_assets can be altered to add new Labeled Sub-Assets The passed in settings can influence how the asset is transformed

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§