Crates.io | goods-reqwest |
lib.rs | goods-reqwest |
version | 0.1.0 |
source | src |
created_at | 2021-02-01 17:15:46.70536 |
updated_at | 2021-02-01 17:15:46.70536 |
description | 'reqwest' based source for 'goods' asset manager |
homepage | |
repository | https://github.com/zakarumych/goods-reqwest |
max_upload_size | |
id | 349339 |
size | 3,877 |
Easy-to-use asset manager for many environments.
Easy-to-use asset manager for many environments.
This crate is written with following goals in mind:
Batteries included.
Extension crates provide variety of useful data sources like FileSource
and ReqwestSource
.
Serde based Format
s are provided by goods-json
, goods-yaml
and goods-ron
.
Extensibility.
Multiple Format
traits can be implemented for any asset type, including foreign asset types.
For example JsonFormat
, YamlFormat
and RonFormat
implement Format
trait for any asset type
which intermediate representation implements serde::de::DeserializeOwned
.
Supporting WebAssembly.
This crate and some of the extension crates are WASM-compatible and no threading is required for asset loading to work.
Types and traits prefixed with Local
remote Send
and Sync
from requirements and bounds.
They can be used in single-threaded environment. Added specifically for WASM where !Send
and !Sync
types are common.
Working with asynchronous data sources.
Raw data sources implement Source
trait.
Source::read
method returns future that will be driven to completion by polling handle to asset.
Fast compilation.
core crate (goods
) build after cargo clean
takes ~1s.
This crate is not aimed to support every possible feature. Here's list of some of those features:
All out-of-the-box functionality exept core traits and types lives in their own goods-*
crates.
goods-dataurl
- providesx DataUrlSource
- reads data embeded directly to url.goods-fs
- provides adds FileSource
- loads asset bytes from file-system.goods-reqwest
- provides ReqwestSource
- loads asset bytes from URLs using reqwest
.
tokio
runtime should be used to poll futures in this case.goods-fetch
- provides FetchSource
- uses browser's Fetch API to load assets data.goods-json
- provides JsonFormat
- treats raw bytes as JSON document and deserializes asset representation via serdegoods-yaml
- provides YamlFormat
- treats raw bytes as YAML document and deserializes asset representation via serdegoods-ron
- provides RonFormat
- treats raw bytes as RON document and deserializes asset representation via serdeThere are few simple examples provided to learn how use this crate.
Shows how to build registry with DataUrlSource
and load simple assets from it.
Shows how to build registry with FileSource
and load simple assets from it.
Async example that loads assets using HTTP protocol with tokio
and reqwest
crates.
Shows how to load assets in browser using Fetch API.
This example can be built using build-wasm32.sh or build-wasm32.bat in examples directory.
wasm-bindgen
(compatible version) must be in PATH
cd examples
build-wasm32 fetch
python3 server.py
Then open http://localhost:8000/fetch.html in your favorite browser. Loaded assets must be shown on the page. Otherwise see for errors in log.
This repository is licensed under either of
at your option.
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.