[][src]Crate goods

Goods - asset manager

Loads only good assets.

Goals

  • Batteries included.
    Crate comes with variety of simple data sources like FileSource and HttpSource. Few Formats based on serde are included under feature flags.

  • Extensible.
    Multiple Format traits can be implemented for any asset type, including foreign asset types.
    For example JsonFormat, YamlFormat and RonFormat (bundled in the crate) implement Format trait for any asset type which intermediate representation implements serde::de::DeserializeOwned.

  • Supporting WebAssembly.
    All mandatory dependencies are WASM-compatible and no threading is required for asset loading to work.

  • Working with asynchronous data sources.
    All data sources implement Source trait. Source::read method returns future that will be driven to completion by the bound Loader.

  • no_std
    alloc is required.

  • Fast compilation.
    build after cargo clean takes ~3s.

Structs

Cache

Asset cache. This type is main entry point for asset loading. Caches loaded assets and provokes loading work for new assets.

Handle

Handle for an asset of type A that eventually resolves to the asset instance or an error.

Loader

Loader receives loading tasks from asset cache and drives them in the async context.

LoaderFlush

Future that polls Loader from which it was created Until no tasks remains.

LoaderRun

Future that polls Loader from which it was created Until Loader is disconnected from all Caches.

PhantomContext

Dummy context for assets that doesn't require one.

Registry

Collection of registered sources. Used by Cache to load new assets.

RegistryBuilder

Builder for source registry.

Enums

Error

Error occured in process of asset loading.

SourceError

Error type for Sources.

Traits

Asset

Loaded, processed and prepared asset. This trait specifies how asset instances can be built from intermediate values that are produced by Format implemetations.

AssetDefaultFormat

Default format for given asset type.

Format

Format trait interprets raw bytes as an asset. It may also use context for asset instance creation and Cache to load compound assets.

LeafFormat

Trait for formats that loads assets immediately.

SimpleAsset

Simplified asset trait to reduce boilerplace when implementing simple assets.

Source

Asset data source.