Trait rustc_metadata::rmeta::table::FixedSizeEncoding

source ·
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§

source

type ByteArray

This should be [u8; BYTE_LEN]; Cannot use an associated const BYTE_LEN: usize instead due to const eval limitations.

Required Methods§

source

fn from_bytes(b: &Self::ByteArray) -> Self

source

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>

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for Option<Constness>

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for Option<CoroutineKind>

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for Option<Defaultness>

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for Option<AssocItemContainer>

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for Option<Asyncness>

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for Option<MacroKind>

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for Option<ImplPolarity>

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for Option<bool>

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for Option<RawDefId>

source§

type ByteArray = [u8; 8]

source§

fn from_bytes(encoded: &[u8; 8]) -> Self

source§

fn write_to_bytes(self, dest: &mut [u8; 8])

source§

impl FixedSizeEncoding for bool

source§

type ByteArray = [u8; 1]

source§

fn from_bytes(b: &[u8; 1]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 1])

source§

impl FixedSizeEncoding for u32

This implementation is not used generically, but for reading/writing concrete u32 fields in Lazy* structures, which may be zero.

source§

type ByteArray = [u8; 4]

source§

fn from_bytes(b: &[u8; 4]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 4])

source§

impl FixedSizeEncoding for u64

source§

type ByteArray = [u8; 8]

source§

fn from_bytes(b: &[u8; 8]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 8])

source§

impl FixedSizeEncoding for UnusedGenericParams

source§

type ByteArray = [u8; 4]

source§

fn from_bytes(b: &[u8; 4]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 4])

source§

impl<T> FixedSizeEncoding for Option<LazyArray<T>>

source§

type ByteArray = [u8; 16]

source§

fn from_bytes(b: &[u8; 16]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 16])

source§

impl<T> FixedSizeEncoding for Option<LazyValue<T>>

source§

type ByteArray = [u8; 8]

source§

fn from_bytes(b: &[u8; 8]) -> Self

source§

fn write_to_bytes(self, b: &mut [u8; 8])

Implementors§