Goods
Easy-to-use asset manager for many environments.
Goals
This crate is written with following goals in mind:
-
Batteries included.
Crate comes with variety of simple data sources likeFileSourceandHttpSource. FewFormats based on serde are included under feature flags. -
Extensibility.
MultipleFormattraits can be implemented for any asset type, including foreign asset types.
For exampleJsonFormat,YamlFormatandRonFormat(bundled in the crate) implementFormattrait for any asset type which intermediate representation implementsserde::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 implementSourcetrait.Source::readmethod returns future that will be driven to completion by the boundLoader. -
no_std
allocis required. -
Fast compilation.
build aftercargo cleantakes ~3s.
Non-Goals
This crate is not aimed to support every possible feature. Here's list of some of those features:
- Hot-reloading
Currently there are no plans to support hot-reloading.
Features
All out-of-the-box functionality execut core traits and types are enabled with features.
std- adds implementation ofstd::error::Errortrait for error types. Enabled by default.sync- makes most typesSendand someSync. Adds requirements for traits implementations to beSendandSyncwhere needed. Enabled by default.fs(enablesstd) - addsFileSource-Sourceimplementation that loads asset bytes from file-system.reqwest- addsReqwestSource-Sourceimplementation that loads asset bytes from URLs usingreqwest. Using this source requiresLoaderto be polled bytokio. Otherwisereqwestinterals will panic.fetch- addsFetchSourcethat uses browser's Fetch API to load assets data. Conflicts withsyncfeature.json-format- addsFormatimplementation that treats asset bytes as JSON document and deserializes asset representation via serdeyaml-format- addsFormatimplementation that treats asset bytes as YAML document and deserializes asset representation via serderon-format- addsFormatimplementation that treats asset bytes as RON document and deserializes asset representation via serde
Examples
There are few simple examples provided already.
fs examlple - shows how to build registry with FileSource and load simple assets from it.
reqwest example - async example that loads assets from localhost over HTTP using tokio and reqwest crates.
legion example - shows how to load assets into entity using legion ECS crate.
fetch example - shows how to load assets in browser using Fetch API.
License
This repository is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution Licensing
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.