hashtree_resolver/lib.rs
1//! Root resolver for hashtree - maps human-readable keys to merkle root hashes
2//!
3//! This crate provides the `RootResolver` trait and implementations for different
4//! backends (Nostr, DNS, HTTP, local storage, etc.)
5//!
6//! # Overview
7//!
8//! A root resolver maps mutable human-readable keys to immutable content-addressed
9//! merkle root hashes. This allows updating what content a key points to while
10//! keeping the underlying data immutable.
11//!
12//! Key format is implementation-specific:
13//! - Nostr: "npub1.../treename"
14//! - DNS: "example.com/treename"
15//! - Local: "local/mydata"
16//!
17//! # Example
18//!
19//! ```rust,ignore
20//! use hashtree_resolver::{RootResolver, ResolverEntry};
21//!
22//! async fn example(resolver: impl RootResolver) {
23//! // One-shot resolve
24//! if let Some(cid) = resolver.resolve("npub1.../mydata").await.unwrap() {
25//! println!("Found cid: {}", cid);
26//! }
27//!
28//! // Subscribe to updates (returns a channel receiver)
29//! let mut rx = resolver.subscribe("npub1.../mydata").await.unwrap();
30//! while let Some(cid) = rx.recv().await {
31//! println!("Updated cid: {:?}", cid);
32//! }
33//! }
34//! ```
35
36mod traits;
37
38#[cfg(feature = "nostr")]
39pub mod nostr;
40
41pub use traits::*;
42
43// Re-export nostr-sdk types for use in NostrResolverConfig
44#[cfg(feature = "nostr")]
45pub use nostr_sdk::prelude::{Keys, ToBech32};