Crate vsdb_trie_db

Source
Expand description

§vsdb_trie_db

Crates.io Docs.rs License Rust

An out-of-box wrapper of the trie_db crate.

This crate provides an out-of-the-box wrapper for trie-db, based on the powerful vsdb crate.

§Installation

Add this to your Cargo.toml:

[dependencies]
vsdb_trie_db = "4.0"

§Usage

vsdb_trie_db provides an out-of-the-box wrapper for the trie-db crate, backed by vsdb.

use vsdb_trie_db::MptStore;

// Create a new MptStore
let mut store = MptStore::new();

// Initialize a new trie with a backend key
let mut trie = store.trie_init(b"my_trie").unwrap();

// Insert a key-value pair
trie.insert(b"key1", b"value1").unwrap();

// Commit the changes to the trie
let mut trie = trie.commit().unwrap();
let root = trie.root();

// Retrieve the value
let value = trie.get(b"key1").unwrap().unwrap();
assert_eq!(value, b"value1");

// Create a read-only handle to the trie at a specific root
let ro_trie = trie.ro_handle(root).unwrap();
let value = ro_trie.get(b"key1").unwrap().unwrap();
assert_eq!(value, b"value1");

§License

This project is licensed under the MIT license.

Structs§

MptOnce
An owned, mutable Merkle Patricia Trie instance.
MptRo
A read-only Merkle Patricia Trie instance.
MptStore
A store for Merkle Patricia Tries (MPTs).

Traits§

ValueEnDe
A trait for both encoding and decoding values.

Type Aliases§

RawBytes
A type alias for a vector of bytes, commonly used for raw data.
RawKey
A type alias for a raw key, represented as a vector of bytes.
RawValue
A type alias for a raw value, represented as a vector of bytes.
TrieIter
An iterator over the items of a Merkle Patricia Trie.
TrieKeyIter
An iterator over the keys of a Merkle Patricia Trie.
TrieRoot
The root hash of a Merkle Patricia Trie.