pub trait Load<C, K, Method = ()>: 'static + Sizedwhere
K: Key,
Method: ?Sized,{
type Error: Display + 'static;
fn load(
key: K,
storage: &mut Storage<C, K>,
ctx: &mut C
) -> Result<Loaded<Self, K>, Self::Error>;
fn reload(
&self,
key: K,
storage: &mut Storage<C, K>,
ctx: &mut C
) -> Result<Self, Self::Error> { ... }
}
Expand description
Class of types that can be loaded and reloaded.
The first type variable, C
, represents the context of the loading. This will be accessed via
a mutable reference when loading and reloading.
The second type variable, K
, is the type of key that can be used to index resources. Some
special resource keys exist:
- [
SimpleKey
]: such a key indexes a resource that lives either on the filesystem or as a logical resource (in-memory, on-the-fly, etc.)
A key type must implement the Key
trait in order to be usable.
The last type variable, Method
, is a tag-only value that is useful to implement several
algorithms to load the same type with different methods.
Required Associated Types§
Required Methods§
sourcefn load(
key: K,
storage: &mut Storage<C, K>,
ctx: &mut C
) -> Result<Loaded<Self, K>, Self::Error>
fn load(
key: K,
storage: &mut Storage<C, K>,
ctx: &mut C
) -> Result<Loaded<Self, K>, Self::Error>
Load a resource.
The Storage
can be used to load additional resource dependencies.
The result type is used to register for dependency events. If you do not need any, you can
lift your return value in Loaded<_>
with your_value.into()
.