## FixedSizeEncoding

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

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

Source§

### impl FixedSizeEncoding for AttrFlags

Source§

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

Source§

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

Source§

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