Struct parity_scale_codec::Compact
source · [−]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
sourceimpl CompactLen<u128> for Compact<u128>
impl CompactLen<u128> for Compact<u128>
sourcefn compact_len(val: &u128) -> usize
fn compact_len(val: &u128) -> usize
Returns the compact encoded length for the given value.
sourceimpl CompactLen<u16> for Compact<u16>
impl CompactLen<u16> for Compact<u16>
sourcefn compact_len(val: &u16) -> usize
fn compact_len(val: &u16) -> usize
Returns the compact encoded length for the given value.
sourceimpl CompactLen<u32> for Compact<u32>
impl CompactLen<u32> for Compact<u32>
sourcefn compact_len(val: &u32) -> usize
fn compact_len(val: &u32) -> usize
Returns the compact encoded length for the given value.
sourceimpl CompactLen<u64> for Compact<u64>
impl CompactLen<u64> for Compact<u64>
sourcefn compact_len(val: &u64) -> usize
fn compact_len(val: &u64) -> usize
Returns the compact encoded length for the given value.
sourceimpl CompactLen<u8> for Compact<u8>
impl CompactLen<u8> for Compact<u8>
sourcefn compact_len(val: &u8) -> usize
fn compact_len(val: &u8) -> usize
Returns the compact encoded length for the given value.
sourceimpl<T> Decode for Compact<T> where
T: CompactAs,
Compact<T::As>: Decode,
impl<T> Decode for Compact<T> where
T: CompactAs,
Compact<T::As>: Decode,
sourcefn 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.
sourcefn skip<I: Input>(input: &mut I) -> Result<(), Error>
fn skip<I: Input>(input: &mut I) -> Result<(), Error>
Attempt to skip the encoded value from input. Read more
sourcefn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
sourceimpl Decode for Compact<()>
impl Decode for Compact<()>
sourcefn 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.
sourcefn skip<I: Input>(input: &mut I) -> Result<(), Error>
fn skip<I: Input>(input: &mut I) -> Result<(), Error>
Attempt to skip the encoded value from input. Read more
sourcefn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
sourceimpl Decode for Compact<u8>
impl Decode for Compact<u8>
sourcefn 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.
sourcefn skip<I: Input>(input: &mut I) -> Result<(), Error>
fn skip<I: Input>(input: &mut I) -> Result<(), Error>
Attempt to skip the encoded value from input. Read more
sourcefn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
sourceimpl Decode for Compact<u16>
impl Decode for Compact<u16>
sourcefn 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.
sourcefn skip<I: Input>(input: &mut I) -> Result<(), Error>
fn skip<I: Input>(input: &mut I) -> Result<(), Error>
Attempt to skip the encoded value from input. Read more
sourcefn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
sourceimpl Decode for Compact<u32>
impl Decode for Compact<u32>
sourcefn 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.
sourcefn skip<I: Input>(input: &mut I) -> Result<(), Error>
fn skip<I: Input>(input: &mut I) -> Result<(), Error>
Attempt to skip the encoded value from input. Read more
sourcefn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
sourceimpl Decode for Compact<u64>
impl Decode for Compact<u64>
sourcefn 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.
sourcefn skip<I: Input>(input: &mut I) -> Result<(), Error>
fn skip<I: Input>(input: &mut I) -> Result<(), Error>
Attempt to skip the encoded value from input. Read more
sourcefn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
sourceimpl Decode for Compact<u128>
impl Decode for Compact<u128>
sourcefn 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.
sourcefn skip<I: Input>(input: &mut I) -> Result<(), Error>
fn skip<I: Input>(input: &mut I) -> Result<(), Error>
Attempt to skip the encoded value from input. Read more
sourcefn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
sourceimpl<'de, T> Deserialize<'de> for Compact<T> where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Compact<T> where
T: Deserialize<'de>,
sourcefn 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
sourceimpl<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,
sourcefn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
sourcefn 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.
sourcefn encode(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn encode(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Convert self to an owned vector.
sourcefn 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.
sourcefn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
sourceimpl<'a, T: 'a> EncodeAsRef<'a, T> for Compact<T> where
CompactRef<'a, T>: Encode + From<&'a T>,
impl<'a, T: 'a> EncodeAsRef<'a, T> for Compact<T> where
CompactRef<'a, T>: Encode + From<&'a T>,
type RefType = CompactRef<'a, T>
type RefType = CompactRef<'a, T>
The reference type that is used for encoding.
sourceimpl MaxEncodedLen for Compact<u8>
impl MaxEncodedLen for Compact<u8>
sourcefn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
sourceimpl MaxEncodedLen for Compact<u16>
impl MaxEncodedLen for Compact<u16>
sourcefn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
sourceimpl MaxEncodedLen for Compact<u32>
impl MaxEncodedLen for Compact<u32>
sourcefn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
sourceimpl MaxEncodedLen for Compact<u64>
impl MaxEncodedLen for Compact<u64>
sourcefn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
sourceimpl MaxEncodedLen for Compact<u128>
impl MaxEncodedLen for Compact<u128>
sourcefn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
sourceimpl<T: Ord> Ord for Compact<T>
impl<T: Ord> Ord for Compact<T>
sourceimpl<T: PartialOrd> PartialOrd<Compact<T>> for Compact<T>
impl<T: PartialOrd> PartialOrd<Compact<T>> for Compact<T>
sourcefn partial_cmp(&self, other: &Compact<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Compact<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Copy> Copy for Compact<T>
impl<T> EncodeLike<Compact<T>> for Compact<T> where
for<'a> CompactRef<'a, T>: Encode,
impl<T: Eq> Eq for Compact<T>
impl<T> StructuralEq for Compact<T>
impl<T> StructuralPartialEq for Compact<T>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more