vessel 0.1.3

A context propogation struct. Carries cancellation, and other useful items transparently through an application
Documentation
  • Coverage
  • 0%
    0 out of 6 items documented0 out of 5 items with examples
  • Size
  • Source code size: 3.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.36 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kjuulh

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 BTreeMap internally 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::Vessel;

let vessel = Vessel::new();
let vessel = vessel.with_value("request_id", "abc-123");

assert_eq!(vessel.get_value("request_id"), Some(&"abc-123".to_string()));

๐Ÿ“š API

pub fn new() -> Self;
pub fn with_value(&self, key: &str, value: &str) -> Self;
pub fn get_value(&self, key: &str) -> Option<&String>;
pub fn get_values(&self) -> &BTreeMap<String, String>;
  • 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:

cargo test

๐Ÿ“œ License

MIT