pub struct Compact<T>(pub T);
Expand description
Compact-encoded variant of T. This is more space-efficient but less compute-efficient.
Tuple Fields§
§0: T
Trait Implementations§
Source§impl CompactLen<u128> for Compact<u128>
impl CompactLen<u128> for Compact<u128>
Source§fn compact_len(val: &u128) -> usize
fn compact_len(val: &u128) -> usize
Returns the compact encoded length for the given value.
Source§impl CompactLen<u16> for Compact<u16>
impl CompactLen<u16> for Compact<u16>
Source§fn compact_len(val: &u16) -> usize
fn compact_len(val: &u16) -> usize
Returns the compact encoded length for the given value.
Source§impl CompactLen<u32> for Compact<u32>
impl CompactLen<u32> for Compact<u32>
Source§fn compact_len(val: &u32) -> usize
fn compact_len(val: &u32) -> usize
Returns the compact encoded length for the given value.
Source§impl CompactLen<u64> for Compact<u64>
impl CompactLen<u64> for Compact<u64>
Source§fn compact_len(val: &u64) -> usize
fn compact_len(val: &u64) -> usize
Returns the compact encoded length for the given value.
Source§impl CompactLen<u8> for Compact<u8>
impl CompactLen<u8> for Compact<u8>
Source§fn compact_len(val: &u8) -> usize
fn compact_len(val: &u8) -> usize
Returns the compact encoded length for the given value.
Source§impl Decode for Compact<()>
impl Decode for Compact<()>
Source§fn decode<I: Input>(_input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(_input: &mut I) -> Result<Self, Error>
Attempt to deserialise the value from input.
Source§fn decode_into<I: Input>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>
fn decode_into<I: Input>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl<T> Decode for Compact<T>
impl<T> Decode for Compact<T>
Source§fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
Attempt to deserialise the value from input.
Source§fn decode_into<I: Input>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>
fn decode_into<I: Input>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl Decode for Compact<u128>
impl Decode for Compact<u128>
Source§fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
Attempt to deserialise the value from input.
Source§fn decode_into<I: Input>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>
fn decode_into<I: Input>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl Decode for Compact<u16>
impl Decode for Compact<u16>
Source§fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
Attempt to deserialise the value from input.
Source§fn decode_into<I: Input>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>
fn decode_into<I: Input>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl Decode for Compact<u32>
impl Decode for Compact<u32>
Source§fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
Attempt to deserialise the value from input.
Source§fn decode_into<I: Input>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>
fn decode_into<I: Input>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl Decode for Compact<u64>
impl Decode for Compact<u64>
Source§fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
Attempt to deserialise the value from input.
Source§fn decode_into<I: Input>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>
fn decode_into<I: Input>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl Decode for Compact<u8>
impl Decode for Compact<u8>
Source§fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
Attempt to deserialise the value from input.
Source§fn decode_into<I: Input>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>
fn decode_into<I: Input>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl<'de, T> Deserialize<'de> for Compact<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Compact<T>where
T: Deserialize<'de>,
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Encode for Compact<T>where
for<'a> CompactRef<'a, T>: Encode,
impl<T> Encode for Compact<T>where
for<'a> CompactRef<'a, T>: Encode,
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
Source§fn encode_to<W: Output + ?Sized>(&self, dest: &mut W)
fn encode_to<W: Output + ?Sized>(&self, dest: &mut W)
Convert self to a slice and append it to the destination.
Source§fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R
fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R
Convert self to a slice and then invoke the given closure with it.
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
Source§impl<'a, T: 'a> EncodeAsRef<'a, T> for Compact<T>
impl<'a, T: 'a> EncodeAsRef<'a, T> for Compact<T>
Source§type RefType = CompactRef<'a, T>
type RefType = CompactRef<'a, T>
The reference type that is used for encoding.
Source§impl<T: Ord> Ord for Compact<T>
impl<T: Ord> Ord for Compact<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Compact<T>
impl<T: PartialOrd> PartialOrd for Compact<T>
impl<T: Copy> Copy for Compact<T>
impl DecodeWithMemTracking for Compact<()>
impl<T> DecodeWithMemTracking for Compact<T>
impl DecodeWithMemTracking for Compact<u128>
impl DecodeWithMemTracking for Compact<u16>
impl DecodeWithMemTracking for Compact<u32>
impl DecodeWithMemTracking for Compact<u64>
impl DecodeWithMemTracking for Compact<u8>
impl<T> EncodeLike for Compact<T>where
for<'a> CompactRef<'a, T>: Encode,
impl<T: Eq> Eq for Compact<T>
impl<T> StructuralPartialEq for Compact<T>
Auto Trait Implementations§
impl<T> Freeze for Compact<T>where
T: Freeze,
impl<T> RefUnwindSafe for Compact<T>where
T: RefUnwindSafe,
impl<T> Send for Compact<T>where
T: Send,
impl<T> Sync for Compact<T>where
T: Sync,
impl<T> Unpin for Compact<T>where
T: Unpin,
impl<T> UnwindSafe for Compact<T>where
T: 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
Mutably borrows from an owned value. Read more