kjuulh 2dc85a4177
All checks were successful
continuous-integration/drone/push Build is passing
feat: use workspace
2025-05-22 11:50:45 +02:00
2025-05-22 11:50:45 +02:00
2025-05-21 08:12:58 +02:00
2025-05-21 08:12:58 +02:00
2025-05-22 11:50:45 +02:00
2025-05-22 11:46:53 +02:00
2025-05-22 11:46:53 +02:00
2025-05-21 08:12:58 +02:00
2025-05-22 11:46:17 +02:00
2025-05-22 11:38:06 +02:00

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

Description
No description provided
Readme 40 KiB
v0.1.3 Latest
2025-05-22 11:47:06 +02:00
Languages
Rust 100%