Trait warmy::Load [] [src]

pub trait Load: 'static + Sized {
    type Key: Into<DepKey>;
    type Error: Error;
    fn load(
        key: Self::Key,
        store: &mut Store
    ) -> Result<Loaded<Self>, Self::Error>; fn reload(
        key: Self::Key,
        store: &mut Store
    ) -> Result<Self, Self::Error> { ... } }

Loadable object from either the file system or memory.

An object can be loaded if it can output a Loaded<_>. It’s important to note that you’re not supposed to use that trait directly. Instead, you should use the Store’s functions.

Associated Types

Type of the key used to load the resource.

You have two choices:

  • PathKey, used to load your resource from the file system.
  • LogicalKey, used to compute your resource from memory.

Type of error that might happen while loading.

Required Methods

Load a resource.

The Store can be used to load or declare additional resource dependencies.

The result type is used to register for dependency events. If you need that feature, you can use the From / Into traits to convert from a key to a DepKey:

Be careful when using this code, it's not being tested!
Ok(Loaded::with_deps(the_resource, vec![a_key.into(), another_key.into()]))

Provided Methods

Function called when a resource must be reloaded.

The default implementation of that function calls load and returns its result.