Struct sp_mmr_primitives::Compact
source · pub struct Compact<H, T> {
pub tuple: T,
/* private fields */
}
Expand description
A composition of multiple leaf elements with compact form representation.
When composing together multiple LeafDataProviders you will end up with
a tuple of LeafData
that each element provides.
However this will cause the leaves to have significant size, while for some use cases it will be enough to prove only one element of the tuple. That’s the rationale for Compact struct. We wrap each element of the tuple into DataOrHash and each tuple element is hashed first before constructing the final hash of the entire tuple. This allows you to replace tuple elements you don’t care about with their hashes.
Fields§
§tuple: T
Internal tuple representation.
Implementations§
Trait Implementations§
source§impl<H, T: Decode> Decode for Compact<H, T>
impl<H, T: Decode> Decode for Compact<H, T>
source§fn decode<I: Input>(value: &mut I) -> Result<Self, Error>
fn decode<I: Input>(value: &mut I) -> Result<Self, Error>
§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self> ) -> Result<DecodeFinished, Error>where I: Input,
§fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error>where I: Input,
§fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
source§impl<H, A> FullLeaf for Compact<H, (DataOrHash<H, A>,)>where
H: Hash,
A: FullLeaf,
impl<H, A> FullLeaf for Compact<H, (DataOrHash<H, A>,)>where H: Hash, A: FullLeaf,
FullLeaf implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
source§impl<H, A, B> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>)>where
H: Hash,
A: FullLeaf,
B: FullLeaf,
impl<H, A, B> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>)>where H: Hash, A: FullLeaf, B: FullLeaf,
FullLeaf implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
source§impl<H, A, B, C> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>, DataOrHash<H, C>)>where
H: Hash,
A: FullLeaf,
B: FullLeaf,
C: FullLeaf,
impl<H, A, B, C> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>, DataOrHash<H, C>)>where H: Hash, A: FullLeaf, B: FullLeaf, C: FullLeaf,
FullLeaf implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
source§impl<H, A, B, C, D> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>, DataOrHash<H, C>, DataOrHash<H, D>)>where
H: Hash,
A: FullLeaf,
B: FullLeaf,
C: FullLeaf,
D: FullLeaf,
impl<H, A, B, C, D> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>, DataOrHash<H, C>, DataOrHash<H, D>)>where H: Hash, A: FullLeaf, B: FullLeaf, C: FullLeaf, D: FullLeaf,
FullLeaf implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
source§impl<H, A, B, C, D, E> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>, DataOrHash<H, C>, DataOrHash<H, D>, DataOrHash<H, E>)>where
H: Hash,
A: FullLeaf,
B: FullLeaf,
C: FullLeaf,
D: FullLeaf,
E: FullLeaf,
impl<H, A, B, C, D, E> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>, DataOrHash<H, C>, DataOrHash<H, D>, DataOrHash<H, E>)>where H: Hash, A: FullLeaf, B: FullLeaf, C: FullLeaf, D: FullLeaf, E: FullLeaf,
FullLeaf implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
source§impl<H, A> LeafDataProvider for Compact<H, (A,)>where
H: Hash,
A: LeafDataProvider,
impl<H, A> LeafDataProvider for Compact<H, (A,)>where H: Hash, A: LeafDataProvider,
LeafDataProvider implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
This provides a compact-form encoding for tuples wrapped in Compact.
source§impl<H, A, B> LeafDataProvider for Compact<H, (A, B)>where
H: Hash,
A: LeafDataProvider,
B: LeafDataProvider,
impl<H, A, B> LeafDataProvider for Compact<H, (A, B)>where H: Hash, A: LeafDataProvider, B: LeafDataProvider,
LeafDataProvider implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
This provides a compact-form encoding for tuples wrapped in Compact.
§type LeafData = Compact<H, (DataOrHash<H, <A as LeafDataProvider>::LeafData>, DataOrHash<H, <B as LeafDataProvider>::LeafData>)>
type LeafData = Compact<H, (DataOrHash<H, <A as LeafDataProvider>::LeafData>, DataOrHash<H, <B as LeafDataProvider>::LeafData>)>
source§impl<H, A, B, C> LeafDataProvider for Compact<H, (A, B, C)>where
H: Hash,
A: LeafDataProvider,
B: LeafDataProvider,
C: LeafDataProvider,
impl<H, A, B, C> LeafDataProvider for Compact<H, (A, B, C)>where H: Hash, A: LeafDataProvider, B: LeafDataProvider, C: LeafDataProvider,
LeafDataProvider implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
This provides a compact-form encoding for tuples wrapped in Compact.
§type LeafData = Compact<H, (DataOrHash<H, <A as LeafDataProvider>::LeafData>, DataOrHash<H, <B as LeafDataProvider>::LeafData>, DataOrHash<H, <C as LeafDataProvider>::LeafData>)>
type LeafData = Compact<H, (DataOrHash<H, <A as LeafDataProvider>::LeafData>, DataOrHash<H, <B as LeafDataProvider>::LeafData>, DataOrHash<H, <C as LeafDataProvider>::LeafData>)>
source§impl<H, A, B, C, D> LeafDataProvider for Compact<H, (A, B, C, D)>where
H: Hash,
A: LeafDataProvider,
B: LeafDataProvider,
C: LeafDataProvider,
D: LeafDataProvider,
impl<H, A, B, C, D> LeafDataProvider for Compact<H, (A, B, C, D)>where H: Hash, A: LeafDataProvider, B: LeafDataProvider, C: LeafDataProvider, D: LeafDataProvider,
LeafDataProvider implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
This provides a compact-form encoding for tuples wrapped in Compact.
§type LeafData = Compact<H, (DataOrHash<H, <A as LeafDataProvider>::LeafData>, DataOrHash<H, <B as LeafDataProvider>::LeafData>, DataOrHash<H, <C as LeafDataProvider>::LeafData>, DataOrHash<H, <D as LeafDataProvider>::LeafData>)>
type LeafData = Compact<H, (DataOrHash<H, <A as LeafDataProvider>::LeafData>, DataOrHash<H, <B as LeafDataProvider>::LeafData>, DataOrHash<H, <C as LeafDataProvider>::LeafData>, DataOrHash<H, <D as LeafDataProvider>::LeafData>)>
source§impl<H, A, B, C, D, E> LeafDataProvider for Compact<H, (A, B, C, D, E)>where
H: Hash,
A: LeafDataProvider,
B: LeafDataProvider,
C: LeafDataProvider,
D: LeafDataProvider,
E: LeafDataProvider,
impl<H, A, B, C, D, E> LeafDataProvider for Compact<H, (A, B, C, D, E)>where H: Hash, A: LeafDataProvider, B: LeafDataProvider, C: LeafDataProvider, D: LeafDataProvider, E: LeafDataProvider,
LeafDataProvider implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
This provides a compact-form encoding for tuples wrapped in Compact.
§type LeafData = Compact<H, (DataOrHash<H, <A as LeafDataProvider>::LeafData>, DataOrHash<H, <B as LeafDataProvider>::LeafData>, DataOrHash<H, <C as LeafDataProvider>::LeafData>, DataOrHash<H, <D as LeafDataProvider>::LeafData>, DataOrHash<H, <E as LeafDataProvider>::LeafData>)>
type LeafData = Compact<H, (DataOrHash<H, <A as LeafDataProvider>::LeafData>, DataOrHash<H, <B as LeafDataProvider>::LeafData>, DataOrHash<H, <C as LeafDataProvider>::LeafData>, DataOrHash<H, <D as LeafDataProvider>::LeafData>, DataOrHash<H, <E as LeafDataProvider>::LeafData>)>
source§impl<H: PartialEq, T: PartialEq> PartialEq<Compact<H, T>> for Compact<H, T>
impl<H: PartialEq, T: PartialEq> PartialEq<Compact<H, T>> for Compact<H, T>
impl<H, T> StructuralPartialEq for Compact<H, T>
Auto Trait Implementations§
impl<H, T> RefUnwindSafe for Compact<H, T>where H: RefUnwindSafe, T: RefUnwindSafe,
impl<H, T> Send for Compact<H, T>where H: Send, T: Send,
impl<H, T> Sync for Compact<H, T>where H: Sync, T: Sync,
impl<H, T> Unpin for Compact<H, T>where H: Unpin, T: Unpin,
impl<H, T> UnwindSafe for Compact<H, T>where H: UnwindSafe, T: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§impl<T> DecodeAll for Twhere
T: Decode,
impl<T> DecodeAll for Twhere T: Decode,
§fn decode_all(input: &mut &[u8]) -> Result<T, Error>
fn decode_all(input: &mut &[u8]) -> Result<T, Error>
Self
and consume all of the given input data. Read more§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere T: Decode,
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
.