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>
source§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,
source§impl<H, A> FullLeaf for Compact<H, (DataOrHash<H, A>,)>
impl<H, A> FullLeaf for Compact<H, (DataOrHash<H, A>,)>
FullLeaf implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
source§impl<H, A, B> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>)>
impl<H, A, B> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>)>
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>)>
impl<H, A, B, C> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>, DataOrHash<H, C>)>
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>)>
impl<H, A, B, C, D> FullLeaf for Compact<H, (DataOrHash<H, A>, DataOrHash<H, B>, DataOrHash<H, C>, DataOrHash<H, D>)>
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>)>
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>)>
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)>
impl<H, A, B> LeafDataProvider for Compact<H, (A, B)>
LeafDataProvider implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
This provides a compact-form encoding for tuples wrapped in Compact.
source§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)>
impl<H, A, B, C> LeafDataProvider for Compact<H, (A, B, C)>
LeafDataProvider implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
This provides a compact-form encoding for tuples wrapped in Compact.
source§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)>
impl<H, A, B, C, D> LeafDataProvider for Compact<H, (A, B, C, D)>
LeafDataProvider implementation for Compact<H, (DataOrHash<H, Tuple>, ...)>
This provides a compact-form encoding for tuples wrapped in Compact.
source§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.
source§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>)>
impl<H, T> StructuralPartialEq for Compact<H, T>
Auto Trait Implementations§
impl<H, T> Freeze for Compact<H, T>where
T: Freeze,
impl<H, T> RefUnwindSafe for Compact<H, T>where
T: RefUnwindSafe,
H: RefUnwindSafe,
impl<H, T> Send for Compact<H, T>
impl<H, T> Sync for Compact<H, T>
impl<H, T> Unpin for Compact<H, T>
impl<H, T> UnwindSafe for Compact<H, T>where
T: UnwindSafe,
H: UnwindSafe,
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> 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> 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
.