Struct sp_mmr_primitives::OpaqueLeaf
source · pub struct OpaqueLeaf(pub Vec<u8>);
Expand description
A helper type to allow using arbitrary SCALE-encoded leaf data in the RuntimeApi.
The point is to be able to verify MMR proofs from external MMRs, where we don’t know the exact leaf type, but it’s enough for us to have it SCALE-encoded.
Note the leaf type should be encoded in its compact form when passed through this type. See FullLeaf documentation for details.
This type does not implement SCALE encoding/decoding on purpose to avoid confusion, it would have to be SCALE-compatible with the concrete leaf type, but due to SCALE limitations it’s not possible to know how many bytes the encoding of concrete leaf type uses.
Tuple Fields§
§0: Vec<u8>
Raw bytes of the leaf type encoded in its compact form.
NOTE it DOES NOT include length prefix (like Vec<u8>
encoding would).
Implementations§
source§impl OpaqueLeaf
impl OpaqueLeaf
sourcepub fn from_leaf<T: FullLeaf>(leaf: &T) -> Self
pub fn from_leaf<T: FullLeaf>(leaf: &T) -> Self
Convert a concrete MMR leaf into an opaque type.
sourcepub fn from_encoded_leaf(encoded_leaf: Vec<u8>) -> Self
pub fn from_encoded_leaf(encoded_leaf: Vec<u8>) -> Self
Create a OpaqueLeaf
given raw bytes of compact-encoded leaf.
sourcepub fn try_decode<T: Decode>(&self) -> Option<T>
pub fn try_decode<T: Decode>(&self) -> Option<T>
Attempt to decode the leaf into expected concrete type.
Trait Implementations§
source§impl Clone for OpaqueLeaf
impl Clone for OpaqueLeaf
source§fn clone(&self) -> OpaqueLeaf
fn clone(&self) -> OpaqueLeaf
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for OpaqueLeaf
impl Debug for OpaqueLeaf
source§impl<'de> Deserialize<'de> for OpaqueLeaf
impl<'de> Deserialize<'de> for OpaqueLeaf
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 FullLeaf for OpaqueLeaf
impl FullLeaf for OpaqueLeaf
source§impl PartialEq<OpaqueLeaf> for OpaqueLeaf
impl PartialEq<OpaqueLeaf> for OpaqueLeaf
source§fn eq(&self, other: &OpaqueLeaf) -> bool
fn eq(&self, other: &OpaqueLeaf) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for OpaqueLeaf
impl Serialize for OpaqueLeaf
impl StructuralPartialEq for OpaqueLeaf
Auto Trait Implementations§
impl RefUnwindSafe for OpaqueLeaf
impl Send for OpaqueLeaf
impl Sync for OpaqueLeaf
impl Unpin for OpaqueLeaf
impl UnwindSafe for OpaqueLeaf
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.