rtb-assets
Part of the phpboyscout Rust toolkit: small, framework-free crates extracted from rust-tool-base.
Lets a Rust binary ship its own defaults and let users override them.
Compile-time embedded assets (rust-embed), physical directories and
in-memory fixtures sit behind one read-only API. Byte reads take the
file from the highest-priority layer that has it, YAML and JSON reads
deep-merge every layer (RFC 7396, so null deletes a key and arrays
replace), and DirectorySource rejects path traversal lexically.
use Assets;
use HashMap;
let assets = builder
.memory
.build;
assert_eq!;
- Docs: https://assets.rust.phpboyscout.uk
- API reference: https://docs.rs/rtb-assets
- Crate: https://crates.io/crates/rtb-assets
Documentation
| Ship defaults a user can override | tutorial: from cargo new to a working overlay |
| Merge layered configuration | how-to, including how to shape a schema that merges well |
| Diagnose a failed asset lookup | how-to: why a read returned nothing |
| Write a custom asset source | how-to: a layer the built-ins do not cover |
| Use assets in tests | how-to: in-memory fixtures in place of files |
| Merge semantics | reference: what merges, what replaces, what deletes |
| What rtb-assets does not do | explanation: the deliberate absences, read before adopting |
Development
just ci runs the full local gate (fmt, clippy, nextest, doc, deny).
Tests include a cucumber BDD suite (tests/bdd.rs). Releases are cut by
colophon from Conventional Commits; do not tag manually.
License
MIT