Struct dotrix_core::assets::Assets[][src]

pub struct Assets { /* fields omitted */ }
Expand description

Assets management service

Stored asset can be identified by its Id. The Id is being assigned to an asset, once the asset is stored.

File operations performed by the service are being executed in separate threads, so no execution blocking happens. Due to some resources may contain several assets, they may not be loaded at the same time. Also bigger assets may take longer time to be loaded.

There is a way to aquire asset Id immediately without awaiting using Assets::register method.

Implementations

Creates new instance of Assets container

Imports an asset file by its path and returns Id of the Resource

Associates an asset name with Id and returns it

If name was already used, then no changes will be done and already associated Id will be returned.

As it was said, names of assets loaded with Assets::import method can be predictable in most cases. Using that prediction, developer can obtain an Id even before calling the Assets::import method.

use dotrix_core::{
    assets::Texture,
    ecs::Mut,
    services::Assets,
};

fn my_system(mut assets: Mut<Assets>) {
    // get the id
    let texture = assets.register::<Texture>("my_texture");
    // import the texture
    assets.import("/path/to/my_texture.png");
}

Stores an asset under user defined name and returns Id of it

Stores an asset and returns Id of it

Searches for an asset by the name and return Id of it if the asset exists

Searches an asset by its Id and returns it by a reference if the asset exists

Searches an asset by its Id and returns it by a mutual reference if the asset exists

Removes an asset from the Service and returns it if the asset exists

Returns iterator over assets by its type

Returns mutable iterator over assets by its type

Trait Implementations

Returns HashMap reference for selected asset type

Returns mutable HashMap reference for selected asset type

Returns HashMap reference for selected asset type

Returns mutable HashMap reference for selected asset type

Returns HashMap reference for selected asset type

Returns mutable HashMap reference for selected asset type

Returns HashMap reference for selected asset type

Returns mutable HashMap reference for selected asset type

Returns HashMap reference for selected asset type

Returns mutable HashMap reference for selected asset type

Returns HashMap reference for selected asset type

Returns mutable HashMap reference for selected asset type

Returns the “default value” for a type. Read more

Executes the destructor for this type. 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

Performs the conversion.

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

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

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