Skip to main content

Crate hashtree_resolver

Crate hashtree_resolver 

Source
Expand description

Root resolver for hashtree - maps human-readable keys to merkle root hashes

This crate provides the RootResolver trait and implementations for different backends (Nostr, DNS, HTTP, local storage, etc.)

§Overview

A root resolver maps mutable human-readable keys to immutable content-addressed merkle root hashes. This allows updating what content a key points to while keeping the underlying data immutable.

Key format is implementation-specific:

  • Nostr: “npub1…/treename”
  • DNS: “example.com/treename”
  • Local: “local/mydata”

§Example

use hashtree_resolver::{RootResolver, ResolverEntry};

async fn example(resolver: impl RootResolver) {
    // One-shot resolve
    if let Some(hash) = resolver.resolve("npub1.../mydata").await.unwrap() {
        println!("Found hash: {}", hashtree_core::to_hex(&hash));
    }

    // Subscribe to updates (returns a channel receiver)
    let mut rx = resolver.subscribe("npub1.../mydata").await.unwrap();
    while let Some(hash) = rx.recv().await {
        println!("Updated hash: {:?}", hash);
    }
}

Structs§

ResolverEntry
Entry in a resolver list

Enums§

ResolverError
Errors that can occur during resolution

Traits§

RootResolver
RootResolver - Maps human-readable keys to content identifiers (Cid)