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§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
source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere T: Decode,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.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> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
§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
.§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.