rustc_metadata::rmeta::table

Trait 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)

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