35 unstable releases
0.29.1 | May 14, 2024 |
---|---|
0.28.0 | Sep 12, 2023 |
0.27.1 | Mar 17, 2023 |
0.24.0 | Aug 4, 2022 |
0.12.2 | Mar 29, 2019 |
#56 in Rust patterns
385,479 downloads per month
Used in 685 crates
(15 directly)
325KB
7.5K
SLoC
Trie
A generic implementation of the Base-16 Modified Merkle Tree ("Trie") data structure, provided under the Apache2 license.
The implementation comes in two formats:
- Trie DB (
trie-db
crate) which can be combined with a backend database to provide a persistent trie structure whose contents can be modified and whose root hash is recalculated efficiently. - Trie Root (
trie-root
crate) which provides a closed-form function that accepts a enumeration of keys and values and provides a root calculated entirely in-memory and closed form.
Trie Hash alone is able to be used in no_std
builds by disabling its (default)
std
feature.
In addition to these, several support crates are provided:
hash-db
crate, used to provideHasher
(trait for all things that can make cryptographic hashes) andHashDB
(trait for databases that can have byte slices pushed into them and allow for them to be retrieved based on their hash). Suitable forno_std
, though in this case will only provideHasher
.memory-db
crate, containsMemoryDB
, an implementation of aHashDB
using only in in-memory map.hash256-std-hasher
crate, an implementation of astd::hash::Hasher
for 32-byte keys that have already been hashed. Useful to build the backingHashMap
forMemoryDB
.
There are also three crates used only for testing:
keccak-hasher
crate, an implementation ofHasher
based on the Keccak-256 algorithm.reference-trie
crate, an implementation of a simple trie format; this provides both aNodeCodec
andTrieStream
implementation making it suitable for both Trie DB and Trie Root.trie-standardmap
crate, a key/value generation tool for creating large test datasets to specific qualities.trie-bench
crate, a comprehensive standard benchmarking tool for trie format implementations. Works using thecriterion
project so benchmarking can be done with the stable rustc branch.
In the spirit of all things Rust, this aims to be reliable, secure, and high performance.
Used in the Substrate project. If you use this crate and would your project listed here, please contact us.
Buidling &c.
Building is done through cargo, as you'd expect.
Building
cargo build --all
Testing
cargo test --all
Benchmarking
cargo bench --all
Building in no_std
cargo build --no-default-features
lib.rs
:
Trie interface and implementation.
Dependencies
~155KB