Vessel
vessel::Vessel is a simple, immutable value bag for Rust โ inspired by Go's context.Context, but focused solely on storing and propagating context in a simple manner.
โจ Features
- Immutable: setting a value returns a new
Vessel. - Ordered: uses a
BTreeMapinternally for deterministic iteration. - Ergonomic: fluent API with zero dependencies (aside from the standard library).
- Useful for threading context-like metadata (e.g., request IDs, tenant info) through application layers.
๐ฆ Example
use Vessel;
let vessel = new;
let vessel = vessel.with_value;
assert_eq!;
๐ API
;
;
;
;
with_value: Adds a key-value pair to the vessel, returning a new instance.get_value: Retrieves a value for a given key.get_values: Returns all key-value pairs.
๐งช Tests
Run tests with:
๐ License
MIT