pub trait Asset<B>:
'static
+ Send
+ Sync
+ Sized {
type Source: 'static + Send + Sync;
type Deps<'a>: Dependencies<'a>;
// Required method
fn upload<'a>(
source: &Self::Source,
backend: &B,
deps: &Self::Deps<'a>,
) -> Option<Self>;
}Expand description
Describes how a source asset of type Self::Source is converted into a
processed asset Self, optionally using a backend B.
B is intentionally generic — it is not restricted to GPU backends:
- CPU → GPU:
Bis your graphics backend (e.g. a wgpuDevice). - CPU → CPU: set
B = ()for pure data transforms (e.g. decoding, decompression, or format conversion with no device required). - Audio / other: set
Bto your audio device or any other service.
§Associated types
Source— the raw unprocessed data stored inAssets<Source>.Deps— zero or more additional resources required during the conversion (seeDependencies). Use()when there are no extra dependencies.
§Upload lifecycle
AssetPlugin drains the dirty queue
from Assets<Source> each tick and calls [upload] for every pending
entry. Returning None re-queues the handle for the next tick, allowing
conversions to wait on sub-resources that may not be ready yet.
Required Associated Types§
Sourcetype Deps<'a>: Dependencies<'a>
type Deps<'a>: Dependencies<'a>
Resources (beyond B itself) required to perform the conversion.
Use () when there are no extra dependencies.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".