pub struct Storage<C, K> { /* private fields */ }
Expand description
Resource storage.
This type is responsible for storing resources, giving functions to look them up and update them whenever needed.
Implementations§
source§impl<C, K> Storage<C, K>where
K: Key,
impl<C, K> Storage<C, K>where
K: Key,
sourcepub fn get<T>(
&mut self,
key: &K,
ctx: &mut C
) -> Result<Res<T>, StoreErrorOr<T, C, K>>where
T: Load<C, K>,
pub fn get<T>(
&mut self,
key: &K,
ctx: &mut C
) -> Result<Res<T>, StoreErrorOr<T, C, K>>where
T: Load<C, K>,
Get a resource from the Storage
and return an error if its loading failed.
This function uses the default loading method.
sourcepub fn get_by<T, M>(
&mut self,
key: &K,
ctx: &mut C,
_: M
) -> Result<Res<T>, StoreErrorOr<T, C, K, M>>where
T: Load<C, K, M>,
pub fn get_by<T, M>(
&mut self,
key: &K,
ctx: &mut C,
_: M
) -> Result<Res<T>, StoreErrorOr<T, C, K, M>>where
T: Load<C, K, M>,
Get a resource from the Storage
by using a specific method and return and error if its
loading failed.
sourcepub fn get_proxied<T, P>(
&mut self,
key: &K,
proxy: P,
ctx: &mut C
) -> Result<Res<T>, StoreError<K>>where
T: Load<C, K>,
P: FnOnce() -> T,
pub fn get_proxied<T, P>(
&mut self,
key: &K,
proxy: P,
ctx: &mut C
) -> Result<Res<T>, StoreError<K>>where
T: Load<C, K>,
P: FnOnce() -> T,
Get a resource from the Storage
for the given key. If it fails, a proxied version is used,
which will get replaced by the resource once it’s available and reloaded.
This function uses the default loading method.
sourcepub fn get_proxied_by<T, M, P>(
&mut self,
key: &K,
proxy: P,
ctx: &mut C,
method: M
) -> Result<Res<T>, StoreError<K>>where
T: Load<C, K, M>,
P: FnOnce() -> T,
pub fn get_proxied_by<T, M, P>(
&mut self,
key: &K,
proxy: P,
ctx: &mut C,
method: M
) -> Result<Res<T>, StoreError<K>>where
T: Load<C, K, M>,
P: FnOnce() -> T,
Get a resource from the Storage
for the given key by using a specific method. If it fails, a
proxied version is used, which will get replaced by the resource once it’s available and
reloaded.