[][src]Trait warmy::load::Load

pub trait Load<C, K, Method = ()>: 'static + Sized where
    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> { ... } }

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.

Associated Types

type Error: Display + 'static

Type of error that might happen while loading.

Loading content...

Required methods

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().

Loading content...

Provided methods

fn reload(
    &self,
    key: K,
    storage: &mut Storage<C, K>,
    ctx: &mut C
) -> Result<Self, Self::Error>

Function called when a resource must be reloaded.

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

Loading content...

Implementors

impl<C, K, T> Load<C, K, Json> for T where
    K: Key + Into<Option<PathBuf>>,
    T: 'static + for<'de> Deserialize<'de>, 
[src]

type Error = JsonError

impl<C, K, T> Load<C, K, Ron> for T where
    K: Key + Into<Option<PathBuf>>,
    T: 'static + for<'de> Deserialize<'de>, 
[src]

type Error = RonError

impl<C, K, T> Load<C, K, Toml> for T where
    K: Key + Into<Option<PathBuf>>,
    T: 'static + for<'de> Deserialize<'de>, 
[src]

type Error = TomlError

Loading content...