rtb-assets 0.6.5

Embedded-asset + overlay filesystem abstraction. Part of the phpboyscout Rust toolkit.
Documentation

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 rtb_assets::Assets;
use std::collections::HashMap;

let assets = Assets::builder()
    .memory(
        "defaults",
        HashMap::from([("greeting.txt".into(), b"hello".to_vec())]),
    )
    .build();

assert_eq!(assets.open_text("greeting.txt").unwrap(), "hello");

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