pub enum NodeHash {
Hashed(H256),
Inline(([u8; 31], u8)),
}Expand description
Struct representing a trie node hash If the encoded node is less than 32 bits, contains the encoded node itself
Variants§
Implementations§
Source§impl NodeHash
impl NodeHash
Sourcepub fn from_encoded(encoded: &[u8], crypto: &(impl Crypto + ?Sized)) -> NodeHash
pub fn from_encoded(encoded: &[u8], crypto: &(impl Crypto + ?Sized)) -> NodeHash
Returns the NodeHash of an encoded node (encoded using the NodeEncoder)
crypto is a generic parameter, here and in every hashing function of
this crate, instead of a &dyn Crypto. Passing a concrete provider to a
&dyn Crypto parameter makes the compiler emit that provider’s whole
vtable, which keeps every one of its methods linked in. This crate names
NativeCrypto where no provider is in scope, so a zkVM guest, which
hashes through its own provider, would also link NativeCrypto’s
modexp, pairing and signature code. With a generic parameter those calls
are dispatched statically and reference keccak256 alone. ?Sized
keeps accepting the callers that hold a &dyn Crypto.
Sourcepub fn finalize(self, crypto: &(impl Crypto + ?Sized)) -> H256
pub fn finalize(self, crypto: &(impl Crypto + ?Sized)) -> H256
Returns the finalized hash NOTE: This will hash smaller nodes, only use to get the final root hash, not for intermediate node hashes
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true if the hash is valid The hash will only be considered invalid if it is empty Aka if it has a default value instead of being a product of hash computation
Sourcepub fn encode<'a>(&self, encoder: Encoder<'a>) -> Encoder<'a>
pub fn encode<'a>(&self, encoder: Encoder<'a>) -> Encoder<'a>
Encodes this NodeHash with the given encoder.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Archive for NodeHash
impl Archive for NodeHash
Source§type Resolver = NodeHashResolver
type Resolver = NodeHashResolver
Source§fn resolve(
&self,
resolver: <Self as Archive>::Resolver,
out: Place<<Self as Archive>::Archived>,
)
fn resolve( &self, resolver: <Self as Archive>::Resolver, out: Place<<Self as Archive>::Archived>, )
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreimpl Copy for NodeHash
Source§impl<'de> Deserialize<'de> for NodeHash
impl<'de> Deserialize<'de> for NodeHash
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<__D: Fallible + ?Sized> Deserialize<NodeHash, __D> for Archived<NodeHash>where
H256Wrapper: ArchiveWith<H256> + DeserializeWith<<H256Wrapper as ArchiveWith<H256>>::Archived, H256, __D>,
([u8; 31], u8): Archive,
<([u8; 31], u8) as Archive>::Archived: Deserialize<([u8; 31], u8), __D>,
impl<__D: Fallible + ?Sized> Deserialize<NodeHash, __D> for Archived<NodeHash>where
H256Wrapper: ArchiveWith<H256> + DeserializeWith<<H256Wrapper as ArchiveWith<H256>>::Archived, H256, __D>,
([u8; 31], u8): Archive,
<([u8; 31], u8) as Archive>::Archived: Deserialize<([u8; 31], u8), __D>,
impl Eq for NodeHash
Source§impl From<NodeHash> for ValueOrHash
impl From<NodeHash> for ValueOrHash
Source§impl Ord for NodeHash
impl Ord for NodeHash
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for NodeHash
impl PartialOrd for NodeHash
Source§impl RLPDecode for NodeHash
impl RLPDecode for NodeHash
fn decode_unfinished(rlp: &[u8]) -> Result<(Self, &[u8]), RLPDecodeError>
fn decode(rlp: &[u8]) -> Result<Self, RLPDecodeError>
impl StructuralPartialEq for NodeHash
Auto Trait Implementations§
impl Forget for NodeHash
impl Freeze for NodeHash
impl Move for NodeHash
impl RefUnwindSafe for NodeHash
impl Send for NodeHash
impl Sync for NodeHash
impl Unpin for NodeHash
impl UnsafeUnpin for NodeHash
impl UnwindSafe for NodeHash
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)
Source§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
fn saturating_into(self) -> U
Source§impl<T, S> SerializeUnsized<S> for T
impl<T, S> SerializeUnsized<S> for T
Source§impl<T> ToDebugString for Twhere
T: Debug,
impl<T> ToDebugString for Twhere
T: Debug,
Source§fn to_debug_string(&self) -> String
fn to_debug_string(&self) -> String
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Upper case
letters are used (e.g. F9B4CA)