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: &dyn Crypto) -> NodeHash
pub fn from_encoded(encoded: &[u8], crypto: &dyn Crypto) -> NodeHash
Returns the NodeHash of an encoded node (encoded using the NodeEncoder)
Sourcepub fn finalize(self, crypto: &dyn Crypto) -> H256
pub fn finalize(self, crypto: &dyn Crypto) -> 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
The resolver for this type. It must contain all the additional
information from serializing needed to make the archived type from
the normal type.
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>, )
Creates the archived version of this value at the given position and
writes it to the given output. Read more
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
An optimization flag that allows the bytes of this type to be copied
directly to a writer instead of calling
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>,
Deserialize this value from the given Serde deserializer. Read more
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,
Compares and returns the maximum of two values. Read more
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 Freeze 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 = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
The archived counterpart of this type. Unlike
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
Creates the archived version of the metadata for this value.
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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>
Returns the layout of the type.
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
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, S> SerializeUnsized<S> for T
impl<T, S> SerializeUnsized<S> for T
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>,
Encode the hex strict representing
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>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)