logo
pub struct Assets<T> where
    T: Asset
{ /* private fields */ }
Expand description

Stores Assets of a given type and tracks changes to them.

Each asset is mapped by a unique HandleId, allowing any Handle with the same HandleId to access it. These assets remain loaded for as long as a Strong handle to that asset exists.

To store a reference to an asset without forcing it to stay loaded, you can use a Weak handle. To make a Weak handle a Strong one, use Assets::get_handle or pass the Assets collection into the handle’s make_strong method.

Remember, if there are no Strong handles for an asset (i.e. they have all been dropped), the asset will unload. Make sure you always have a Strong handle when you want to keep an asset loaded!

Implementations

Adds an asset to the collection, returning a Strong handle to that asset.

Events

Add/modify the asset pointed to by the given handle.

Unless there exists another Strong handle for this asset, it’s advised to use the returned Strong handle. Not doing so may result in the unexpected release of the asset.

See set_untracked for more info.

Add/modify the asset pointed to by the given handle.

If an asset already exists with the given HandleId, it will be modified. Otherwise the new asset will be inserted.

Events

Get the asset for the given handle.

This is the main method for accessing asset data from an Assets collection. If you need mutable access to the asset, use get_mut.

Checks if an asset exists for the given handle

Get mutable access to the asset for the given handle.

This is the main method for mutably accessing asset data from an Assets collection. If you do not need mutable access to the asset, you may also use get.

Gets a Strong handle pointing to the same asset as the given one

Get mutable access to an asset for the given handle, inserting a new value if none exists.

Events

Get an iterator over all assets in the collection.

Get a mutable iterator over all assets in the collection.

Get an iterator over all HandleId’s in the collection.

Remove an asset for the given handle.

The asset is returned if it existed in the collection, otherwise None.

Events

Clears the inner asset map, removing all key-value pairs.

Keeps the allocated memory for reuse.

Reserves capacity for at least additional more elements to be inserted into the assets.

The collection may reserve more space to avoid frequent reallocations.

Shrinks the capacity of the asset map as much as possible.

It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.

Gets the number of assets in the collection

Returns true if there are no stored assets

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more