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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

#### 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.

§

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

§

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

§

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

§

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

§

#### type ByteArray = [u8; 8]

source§

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

source§

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

## Implementors§

source§

### impl FixedSizeEncoding for AttrFlags

§

#### type ByteArray = [u8; 1]

source§

### impl<T> FixedSizeEncoding for LazyArray<T>

§

#### type ByteArray = [u8; 16]