diff --git a/Cargo.lock b/Cargo.lock index 7fbf608..0423cbc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "anyhow" -version = "1.0.98" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" - [[package]] name = "vessel" version = "0.1.1" -dependencies = [ - "anyhow", -] diff --git a/Cargo.toml b/Cargo.toml index a06ad5d..c528c6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,3 @@ resolver = "2" [workspace.dependencies] vessel = { path = "crates/vessel" } - -anyhow = { version = "1.0.71" } diff --git a/README.md b/README.md new file mode 100644 index 0000000..0eb70b9 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# 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 + +```rust +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 + +```rust +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; +``` + +* `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: + +```bash +cargo test +``` + +## ๐Ÿ”’ Stability + +The crate is small and intentionally limited in scope. You can depend on its behavior being stable. + +## ๐Ÿ“œ License + +MIT + diff --git a/crates/vessel/Cargo.toml b/crates/vessel/Cargo.toml index b9f6383..92c58c8 100644 --- a/crates/vessel/Cargo.toml +++ b/crates/vessel/Cargo.toml @@ -3,7 +3,5 @@ name = "vessel" version = "0.1.1" edition = "2024" description = "A context propogation struct. Carries cancellation, and other useful items transparently through an application" +readme = "../../README.md" license = "MIT" - -[dependencies] -anyhow.workspace = true