Trait asset_store::AssetStore
[-]
[+]
[src]
pub trait AssetStore<E> { fn load(&self, path: &str); fn is_loaded(&self, path: &str) -> Result<bool, E>; fn unload(&self, path: &str); fn unload_everything(&self); fn map_resource<O>(&self, path: &str, mapfn: |&[u8]| -> O) -> Result<Option<O>, E>; fn map_resource_block<O>(&self, path: &str, mapfn: |&[u8]| -> O) -> Result<O, E>; fn load_all<'a, I: Iterator<&'a str>>(&self, paths: I) { ... } fn all_loaded<'a, I: Iterator<&'a str>>(&self, paths: I) -> Result<bool, Vec<(&'a str, E)>> { ... } fn unload_all<'a, I: Iterator<&'a str>>(&self, paths: I) { ... } fn with_bytes(&self, path: &str, with_fn: |&[u8]|) -> Result<Option<()>, E> { ... } fn with_bytes_block(&self, path: &str, with_fn: |&[u8]|) -> Result<(), E> { ... } }
Required Methods
fn load(&self, path: &str)
Tell the asset store to begin loading a resource.
fn is_loaded(&self, path: &str) -> Result<bool, E>
Check to see if a resource has been loaded or not.
fn unload(&self, path: &str)
Remove this resouce from this asset store if it is loaded.
fn unload_everything(&self)
Remove every resouce from this asset store
fn map_resource<O>(&self, path: &str, mapfn: |&[u8]| -> O) -> Result<Option<O>, E>
Given a path to a resource and a transformation function, returns the result of the transformation function applied to the bytes of the resource if that resource is loaded.
Returns Ok(value)
if the resource is loaded and where value
is the result of the transformation.
Returns Ok(None) if the resource is not yet loaded.
Returns Err(e) if the resource failed to open with an error.
fn map_resource_block<O>(&self, path: &str, mapfn: |&[u8]| -> O) -> Result<O, E>
See map_resource
. This function blocks on read, so the only
possible return values are Ok(value)
, or Err(e)
.
Provided Methods
fn load_all<'a, I: Iterator<&'a str>>(&self, paths: I)
Tell the asset store to begin loading all resources.
fn all_loaded<'a, I: Iterator<&'a str>>(&self, paths: I) -> Result<bool, Vec<(&'a str, E)>>
Check to see if everything has been loaded.
fn unload_all<'a, I: Iterator<&'a str>>(&self, paths: I)
Remove all these resouces from this asset store if they are loaded.
fn with_bytes(&self, path: &str, with_fn: |&[u8]|) -> Result<Option<()>, E>
Similar to map_resource, the user provides a path and a
function. The function is run only if the file is loaded
without error. The return value of the provided function
is ignored, and a status is returned in the format given by
map_resource, but with the uint ()
value in place of
a mapped value.
fn with_bytes_block(&self, path: &str, with_fn: |&[u8]|) -> Result<(), E>
The same as with_bytes_block
but blocking.
Implementors
impl<T: 'static> AssetStore<MultiStoreError<T>> for MultiStore<T>
impl<B: IoBackend> AssetStore<IoError> for IoStore<B>
impl AssetStore<StaticStoreError> for StaticStore