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)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so 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.