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: TTrait Implementations§
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 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<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.
impl<T> Copy for Compact<T>where
T: Copy,
Source§impl<T> Decode for Compact<T>
impl<T> Decode for Compact<T>
Source§fn decode<I>(input: &mut I) -> Result<Compact<T>, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<Compact<T>, Error>where
I: Input,
Attempt to deserialise the value from input.
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,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl Decode for Compact<()>
impl Decode for Compact<()>
Source§fn decode<I>(_input: &mut I) -> Result<Compact<()>, Error>where
I: Input,
fn decode<I>(_input: &mut I) -> Result<Compact<()>, Error>where
I: Input,
Attempt to deserialise the value from input.
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,
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: &mut I) -> Result<Compact<u8>, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<Compact<u8>, Error>where
I: Input,
Attempt to deserialise the value from input.
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,
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: &mut I) -> Result<Compact<u16>, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<Compact<u16>, Error>where
I: Input,
Attempt to deserialise the value from input.
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,
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: &mut I) -> Result<Compact<u32>, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<Compact<u32>, Error>where
I: Input,
Attempt to deserialise the value from input.
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,
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: &mut I) -> Result<Compact<u64>, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<Compact<u64>, Error>where
I: Input,
Attempt to deserialise the value from input.
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,
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: &mut I) -> Result<Compact<u128>, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<Compact<u128>, Error>where
I: Input,
Attempt to deserialise the value from input.
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,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
impl<T> DecodeWithMemTracking for Compact<T>
impl DecodeWithMemTracking for Compact<()>
impl DecodeWithMemTracking for Compact<u8>
impl DecodeWithMemTracking for Compact<u16>
impl DecodeWithMemTracking for Compact<u32>
impl DecodeWithMemTracking for Compact<u64>
impl DecodeWithMemTracking for Compact<u128>
Source§impl<'de, T> Deserialize<'de> for Compact<T>where
T: Deserialize<'de>,
Available on crate feature serde only.
impl<'de, T> Deserialize<'de> for Compact<T>where
T: Deserialize<'de>,
Available on crate feature
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<Compact<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Compact<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Encode for Compact<T>where
CompactRef<'a, T>: for<'a> Encode,
impl<T> Encode for Compact<T>where
CompactRef<'a, T>: for<'a> 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>(&self, dest: &mut W)
fn encode_to<W>(&self, dest: &mut W)
Convert self to a slice and append it to the destination.
Source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&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> EncodeAsRef<'a, T> for Compact<T>
impl<'a, T> 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.
impl<T> EncodeLike for Compact<T>where
CompactRef<'a, T>: for<'a> Encode,
impl<T> Eq for Compact<T>where
T: Eq,
Source§impl<T> Ord for Compact<T>where
T: Ord,
impl<T> Ord for Compact<T>where
T: Ord,
1.21.0 (const: unstable) · 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> PartialEq for Compact<T>where
T: PartialEq,
impl<T> PartialEq for Compact<T>where
T: PartialEq,
Source§impl<T> PartialOrd for Compact<T>where
T: PartialOrd,
impl<T> PartialOrd for Compact<T>where
T: PartialOrd,
Source§impl<T> Serialize for Compact<T>where
T: Serialize,
Available on crate feature serde only.
impl<T> Serialize for Compact<T>where
T: Serialize,
Available on crate feature
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
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> UnsafeUnpin for Compact<T>where
T: UnsafeUnpin,
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