[][src]Struct amethyst_assets::AssetStorage

pub struct AssetStorage<A: Asset> { /* fields omitted */ }

An asset storage, storing the actual assets and allocating handles to them.

Methods

impl<A: Asset> AssetStorage<A>[src]

pub fn new() -> Self[src]

Creates a new asset storage.

pub fn unload_all(&mut self)[src]

Remove all data from asset storages, invalidating all associated handles. Trying to retreive any data using old handle will return None.

pub fn clone_asset(&mut self, handle: &Handle<A>) -> Option<Handle<A>> where
    A: Clone
[src]

When cloning an asset handle, you'll get another handle, but pointing to the same asset. If you instead want to indeed create a new asset, you can use this method. Note however, that it needs a mutable borrow of self, so it can't be used in parallel.

pub fn get(&self, handle: &Handle<A>) -> Option<&A>[src]

Get an asset from a given asset handle.

pub fn get_version(&self, handle: &Handle<A>) -> Option<u32>[src]

Get an asset version from a given asset handle.

pub fn get_with_version(&self, handle: &Handle<A>) -> Option<&(A, u32)>[src]

Get an asset and it's version from a given asset handle.

pub fn get_by_id(&self, id: u32) -> Option<&A>[src]

Get an asset by it's handle id.

pub fn replace(&mut self, handle: &Handle<A>, asset: A) -> A[src]

Replace asset under given handle, incrementing the version id. Returns old asset. Panics if asset handle is empty.

pub fn insert(&mut self, asset: A) -> Handle<A>[src]

Insert preloaded asset into storage synchronously without going through usual loading step. You probably want to use Loader::load instead.

Use this method only when you need to insert procedurally generated asset directly into storage, skipping intermediate Asset::Data form.

pub fn contains(&self, handle: &Handle<A>) -> bool[src]

Check if given handle points to a valid asset in the storage.

pub fn contains_id(&self, id: u32) -> bool[src]

Check if given asset id points to a valid asset in the storage.

pub unsafe fn get_by_id_unchecked(&self, id: u32) -> &A[src]

Get an asset by it's handle id without checking the internal bitset. Use contains_id to manually check it's status before access.

Safety

You must manually verify that given asset id is valid. Failing to do so may result in dereferencing uninitialized memory or out of bounds access.

pub fn get_mut(&mut self, handle: &Handle<A>) -> Option<&mut A>[src]

Get an asset mutably from a given asset handle.

pub fn process<F>(
    &mut self,
    f: F,
    frame_number: u64,
    pool: &ThreadPool,
    strategy: Option<&HotReloadStrategy>
) where
    F: FnMut(A::Data) -> Result<ProcessingState<A>, Error>, 
[src]

Process finished asset data and maintain the storage.

pub fn process_custom_drop<F, D>(
    &mut self,
    f: F,
    drop_fn: D,
    frame_number: u64,
    pool: &ThreadPool,
    strategy: Option<&HotReloadStrategy>
) where
    D: FnMut(A),
    F: FnMut(A::Data) -> Result<ProcessingState<A>, Error>, 
[src]

Process finished asset data and maintain the storage. This calls the drop_fn closure for assets that were removed from the storage.

Trait Implementations

impl<A: Asset> Default for AssetStorage<A>[src]

impl<A: Asset> Drop for AssetStorage<A>[src]

Auto Trait Implementations

impl<A> Send for AssetStorage<A> where
    <A as Asset>::Data: Send

impl<A> Sync for AssetStorage<A> where
    <A as Asset>::Data: Send

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Same for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf for SP where
    SS: SubsetOf<SP>, 

impl<T> Event for T where
    T: Send + Sync + 'static, 

impl<T> Resource for T where
    T: Any + Send + Sync

impl<T> TryDefault for T where
    T: Default

fn unwrap_default() -> Self

Calls try_default and panics on an error case.

impl<T> Any for T where
    T: Any

impl<T> Erased for T