Trait warmy::load::Load
[−]
[src]
pub trait Load<C, Method = ()>: 'static + Sized where
Method: ?Sized, { type Key: Key + 'static; type Error: Error + 'static; fn load(
key: Self::Key,
storage: &mut Storage<C>,
ctx: &mut C
) -> Result<Loaded<Self>, Self::Error>; fn reload(
&self,
key: Self::Key,
storage: &mut Storage<C>,
ctx: &mut C
) -> Result<Self, Self::Error> { ... } }
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, Method
, is a tag-only value that is useful to implement several
algorithms to load the same type with different methods.
Associated Types
type Key: Key + 'static
Type of the key used to load the resource.
type Error: Error + 'static
Type of error that might happen while loading.
Required Methods
fn load(
key: Self::Key,
storage: &mut Storage<C>,
ctx: &mut C
) -> Result<Loaded<Self>, Self::Error>
key: Self::Key,
storage: &mut Storage<C>,
ctx: &mut C
) -> Result<Loaded<Self>, 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()
.
Provided Methods
fn reload(
&self,
key: Self::Key,
storage: &mut Storage<C>,
ctx: &mut C
) -> Result<Self, Self::Error>
&self,
key: Self::Key,
storage: &mut Storage<C>,
ctx: &mut C
) -> Result<Self, Self::Error>
Function called when a resource must be reloaded.
The default implementation of that function calls load
and returns its result.