reth_trie_common/
storage.rsuse super::{BranchNodeCompact, StoredNibblesSubKey};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
pub struct StorageTrieEntry {
pub nibbles: StoredNibblesSubKey,
pub node: BranchNodeCompact,
}
#[cfg(any(test, feature = "reth-codec"))]
impl reth_codecs::Compact for StorageTrieEntry {
fn to_compact<B>(&self, buf: &mut B) -> usize
where
B: bytes::BufMut + AsMut<[u8]>,
{
let nibbles_len = self.nibbles.to_compact(buf);
let node_len = self.node.to_compact(buf);
nibbles_len + node_len
}
fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) {
let (nibbles, buf) = StoredNibblesSubKey::from_compact(buf, 33);
let (node, buf) = BranchNodeCompact::from_compact(buf, len - 33);
let this = Self { nibbles, node };
(this, buf)
}
}