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 for OpaqueLeaf
impl PartialEq for OpaqueLeaf
source§impl Serialize for OpaqueLeaf
impl Serialize for OpaqueLeaf
impl StructuralPartialEq for OpaqueLeaf
Auto Trait Implementations§
impl Freeze for OpaqueLeaf
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> 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> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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> 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, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> 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 S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.