| Crates.io | hashtree-core |
| lib.rs | hashtree-core |
| version | 0.2.3 |
| created_at | 2025-12-17 15:36:06.238029+00 |
| updated_at | 2026-01-19 13:10:13.357492+00 |
| description | Simple content-addressed merkle tree with KV storage |
| homepage | |
| repository | https://files.iris.to/#/npub1xndmdgymsf4a34rzr7346vp8qcptxf75pjqweh8naa8rklgxpfqqmfjtce/hashtree |
| max_upload_size | |
| id | 1990540 |
| size | 341,104 |
Simple content-addressed merkle tree with KV storage.
This is the core library that implements the merkle tree structure used by hashtree. It provides:
use hashtree_core::{HashTree, HashTreeConfig, store::MemoryStore};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = Arc::new(MemoryStore::new());
let tree = HashTree::new(HashTreeConfig::new(store));
// Store content (encrypted by default)
let cid = tree.put(b"Hello, World!").await?;
// Read it back
let data = tree.get(&cid).await?;
Ok(())
}
Every stored item is either raw bytes or a tree node. Tree nodes are MessagePack-encoded with a type field:
Blob (0) - Raw data chunkFile (1) - Chunked file: links are unnamed, ordered by byte offsetDir (2) - Directory: links have names, may point to files or subdirsThe Store trait is just get(hash) → bytes and put(hash, bytes). Works with any backend that can store/fetch by hash.
Part of hashtree-rs.