[−][src]Trait rustc_metadata::rmeta::table::FixedSizeEncoding

pub(super) trait FixedSizeEncoding: Default {
    const BYTE_LEN: usize;

    fn from_bytes(b: &[u8]) -> Self;
fn write_to_bytes(self, b: &mut [u8]);
fn maybe_read_from_bytes_at(b: &[u8], i: usize) -> Option<Self>;
fn write_to_bytes_at(self, b: &mut [u8], i: usize); }

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.

Associated Constants

const BYTE_LEN: usize

Loading content...

Required methods

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

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

fn maybe_read_from_bytes_at(b: &[u8], i: usize) -> Option<Self>

Read a Self value (encoded as Self::BYTE_LEN bytes), from &b[i * Self::BYTE_LEN..], returning None if i is not in bounds, or Some(Self::from_bytes(...)) otherwise.

fn write_to_bytes_at(self, b: &mut [u8], i: usize)

Write a Self value (encoded as Self::BYTE_LEN bytes), at &mut b[i * Self::BYTE_LEN..], using Self::write_to_bytes.

Loading content...

Implementations on Foreign Types

impl FixedSizeEncoding for u32[src]

impl<T> FixedSizeEncoding for Option<Lazy<T>>[src]

impl<T> FixedSizeEncoding for Option<Lazy<[T]>>[src]

Loading content...

Implementors

Loading content...