pub(super) trait FixedSizeEncoding: IsDefault {
type ByteArray;
// Required methods
fn from_bytes(b: &Self::ByteArray) -> Self;
fn write_to_bytes(self, b: &mut Self::ByteArray);
}
Expand description
Helper trait, for encoding to, and decoding from, a fixed number of bytes.
Used mainly for Lazy positions and lengths.
Unchecked invariant: Self::default()
should encode as [0; BYTE_LEN]
,
but this has no impact on safety.
Required Associated Types§
Required Methods§
fn from_bytes(b: &Self::ByteArray) -> Self
fn write_to_bytes(self, b: &mut Self::ByteArray)
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl FixedSizeEncoding for Option<DefKind>
impl FixedSizeEncoding for Option<DefKind>
source§impl FixedSizeEncoding for Option<Constness>
impl FixedSizeEncoding for Option<Constness>
source§impl FixedSizeEncoding for Option<CoroutineKind>
impl FixedSizeEncoding for Option<CoroutineKind>
source§impl FixedSizeEncoding for Option<Defaultness>
impl FixedSizeEncoding for Option<Defaultness>
source§impl FixedSizeEncoding for Option<AssocItemContainer>
impl FixedSizeEncoding for Option<AssocItemContainer>
source§impl FixedSizeEncoding for Option<Asyncness>
impl FixedSizeEncoding for Option<Asyncness>
source§impl FixedSizeEncoding for Option<MacroKind>
impl FixedSizeEncoding for Option<MacroKind>
source§impl FixedSizeEncoding for Option<ImplPolarity>
impl FixedSizeEncoding for Option<ImplPolarity>
source§impl FixedSizeEncoding for Option<bool>
impl FixedSizeEncoding for Option<bool>
source§impl FixedSizeEncoding for Option<RawDefId>
impl FixedSizeEncoding for Option<RawDefId>
source§impl FixedSizeEncoding for bool
impl FixedSizeEncoding for bool
source§impl FixedSizeEncoding for u32
impl FixedSizeEncoding for u32
This implementation is not used generically, but for reading/writing
concrete u32
fields in Lazy*
structures, which may be zero.