### trie_db Crate Modules API Reference Source: https://docs.rs/trie-db/0.30.0/trie_db/trie_db This section provides an overview of the modules available in the `trie_db` crate, detailing their purpose and functionality. It includes modules for nibble operations, node management, proof generation, trie query recording, and various trie database implementations. ```APIDOC Modules: - nibble_ops: Utility methods to work on radix 16 nibble. - node - proof: Generation and verification of compact proofs for Merkle-Patricia tries. - recorder: Trie query recorder. - sectriedb - sectriedbmut - triedb - triedbmut: In-memory trie representation. ``` -------------------------------- ### Rust trie_db Structs API Reference Source: https://docs.rs/trie-db/0.30.0/trie_db/trie_db Defines various structs used in the trie_db library, including data containers, trie implementations, iterators, and utility objects for trie manipulation. These structs form the building blocks for interacting with and managing Merkle Patricia Tries. ```APIDOC Structs: Bytes: A container for storing bytes. BytesWeak: A weak reference of `Bytes`. FatDB: A `Trie` implementation which hashes keys and uses a generic `HashDB` backing database. Additionally it stores inserted hash-key mappings for later retrieval. FatDBIterator: Iterator over inserted pairs of key values. FatDBMut: A mutable `Trie` implementation which hashes keys and uses a generic `HashDB` backing database. Additionally it stores inserted hash-key mappings for later retrieval. Lookup: Trie lookup helper object. NibbleSlice: Nibble-orientated view onto byte-slice, allowing nibble-precision offsets. NibbleVec: Owning, nibble-oriented byte vector. Counterpart to `NibbleSlice`. Nibbles are always left aligned, so making a `NibbleVec` from a `NibbleSlice` can get costly. TrieBuilder: Get trie root and insert visited node in a hash_db. As for all `ProcessEncodedNode` implementation, it is only for full trie parsing (not existing trie). TrieDBNodeDoubleEndedIterator: Double ended iterator for going through all nodes in the trie in pre-order traversal order. TrieDBNodeIterator: Iterator for going through all nodes in the trie in pre-order traversal order. TrieDBRawIterator: Iterator for going through all nodes in the trie in pre-order traversal order. TrieFactory: Trie factory. TrieRoot: Calculate the trie root of the trie. TrieRootPrint: Calculate the trie root of the trie. Print a debug trace. TrieRootUnhashed: Get the trie root node encoding. ``` -------------------------------- ### trie_db Rust Functions API Reference Source: https://docs.rs/trie-db/0.30.0/trie_db/trie_db Provides utility functions for encoding, decoding, and visiting trie structures, facilitating compact representation and traversal. These functions are essential for managing the trie's data efficiently. ```APIDOC decode_compact: Reconstructs a partial trie DB from a compact representation. The encoding is a vector of mutated trie nodes with those child references omitted. The decode function reads them in order from the given slice, reconstructing the full nodes and inserting them into the given `HashDB`. It stops after fully constructing one partial trie and returns the root hash and the number of nodes read. If an error occurs during decoding, there are no guarantees about which entries were or were not added to the DB. decode_compact_from_iter: Variant of ‘decode_compact’ that accept an iterator of encoded nodes as input. encode_compact: Generates a compact representation of the partial trie stored in the given DB. The encoding is a vector of mutated trie nodes with those child references omitted. The mutated trie nodes are listed in pre-order traversal order so that the full nodes can be efficiently reconstructed recursively. trie_visit: Function visiting trie from key value inputs with a `ProccessEncodedNode` callback. This is the main entry point of this module. Calls to each node occurs ordered by byte key value but with longest keys first (from node to branch to root), this differs from standard byte array ordering a bit. ``` -------------------------------- ### Rust Re-exports for trie_db Crate Source: https://docs.rs/trie-db/0.30.0/trie_db/trie_db This section lists the public re-exports from various modules within the `trie_db` crate, making key structs and enums directly accessible from the crate root. These re-exports simplify access to core components like `Recorder`, `SecTrieDB`, `TrieDB`, and their mutable counterparts. ```Rust pub use self::recorder::Recorder; pub use self::sectriedb::SecTrieDB; pub use self::sectriedbmut::SecTrieDBMut; pub use self::triedb::TrieDB; pub use self::triedb::TrieDBBuilder; pub use self::triedb::TrieDBIterator; pub use self::triedb::TrieDBKeyIterator; pub use self::triedbmut::ChildReference; pub use self::triedbmut::TrieDBMut; pub use self::triedbmut::TrieDBMutBuilder; pub use self::triedbmut::Value; ``` -------------------------------- ### trie_db Rust Traits API Reference Source: https://docs.rs/trie-db/0.30.0/trie_db/trie_db Defines core traits for interacting with the trie database, including hashing, node encoding, querying, and trie structure. These traits abstract common functionalities and allow for flexible implementations. ```APIDOC HashDB: Trait modelling datastore keyed by a hash defined by the `Hasher`. HashDBRef: Trait for immutable reference of HashDB. Hasher: Trait describing an object that can hash a slice of bytes. Used to abstract other types over the hashing algorithm. Defines a single `hash` method and an `Out` associated type with the necessary bounds. NodeCodec: Trait for trie node encoding/decoding. Uses a type parameter to allow registering positions without colling decode plan. ProcessEncodedNode: Visitor trait to implement when using `trie_visit`. Query: Description of what kind of query will be made to the trie. Trie: A key-value datastore implemented as a database-backed modified Merkle tree. TrieCache: A cache that can be used to speed-up certain operations when accessing the trie. TrieConfiguration: This trait associates a trie definition with preferred methods. It also contains own default implementations and can be used to allow switching implementation. TrieDoubleEndedIterator: Extending the `TrieIterator` trait with `DoubleEndedIterator` trait. TrieIterator: A trie iterator that also supports random access (`seek()`). TrieLayout: Trait with definition of trie layout. Contains all associated trait needed for a trie definition or implementation. TrieMut: A key-value datastore implemented as a database-backed modified Merkle tree. TrieRecorder: A trie recorder that can be used to record all kind of `TrieAccess`’s. ``` -------------------------------- ### trie_db Rust Type Aliases API Reference Source: https://docs.rs/trie-db/0.30.0/trie_db/trie_db Defines convenient type aliases for common data structures and results within the trie database context. These aliases simplify type declarations and improve code readability. ```APIDOC CError: Alias accessor to `NodeCodec` associated `Error` type from a `TrieLayout`. DBValue: Database value Partial: Representation of a nible slice (right aligned). It contains a right aligned padded first byte (first pair element is the number of nibbles (0 to max nb nibble - 1), second pair element is the padded nibble), and a slice over the remaining bytes. Result: Trie result type. Boxed to avoid copying around extra space for the `Hasher`s `Out` on successful queries. TrieHash: Alias accessor to hasher hash output type from a `TrieLayout`. TrieItem: Trie-Item type used for iterators over trie data. TrieKeyItem: Trie-Item type used for iterators over trie key only. ``` -------------------------------- ### Rust trie_db Enums API Reference Source: https://docs.rs/trie-db/0.30.0/trie_db/trie_db Defines various enums used in the trie_db library, representing cached values, merkle values, recording results, trie access types, errors, and different trie kinds/specs. These enums provide structured ways to handle different states and types within the trie database system. ```APIDOC Enums: CachedValue: A value as cached by the `TrieCache`. MerkleValue: Either the `hash` or `value` of a node depending on its size. RecordedForKey: Result of `TrieRecorder::trie_nodes_recorded_for_key`. TrieAccess: Used to report the trie access to the `TrieRecorder`. TrieError: Trie Errors. TrieKinds: All different kinds of tries. This is used to prevent a heap allocation for every created trie. TrieSpec: Trie types ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.