Skip to main content

asset

Macro asset 

Source
macro_rules! asset {
    ($ty:ty => $processed:ty, |$self:ident, $backend:ident : &$backend_ty:ty| $body:block) => { ... };
    ($ty:ty => $processed:ty, deps: [$dep:ty], |$self:ident, $backend:ident : &$backend_ty:ty, $deps:ident| $body:block) => { ... };
    ($ty:ty => $processed:ty, deps: [$($dep:ty),+ $(,)?], |$self:ident, $backend:ident : &$backend_ty:ty, $deps:ident| $body:block) => { ... };
}
Expand description

Expands to the same AssetSource/Asset<B> impls you’d write by hand — a pure syntax transform, so every built-in asset type keeps using the trait impls directly. Only exists to make a new, user-defined asset type cheaper to write:

asset!(MyThing => GPUMyThing, |self, backend: &Backend| {
    Some(GPUMyThing { .. })
});

asset!(MyThing => GPUMyThing, deps: [SomePool], |self, backend: &Backend, deps| {
    Some(GPUMyThing { .. })
});

deps: [..] takes bare types — wrapped in Read<'a, _> for one, or a tuple of Read<'a, _> for several (matching what Dependencies supports).