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

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

    pub(in rmeta) fn from_bytes(
        b: &[u8]
    ) -> Self;
pub(in rmeta) fn write_to_bytes(
        self,
        b: &mut [u8]
    );
pub(in rmeta) fn maybe_read_from_bytes_at(
        b: &[u8],
        i: usize
    ) -> Option<Self>;
pub(in rmeta) 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

pub(in rmeta) const BYTE_LEN: usize[src]

Loading content...

Required methods

pub(in rmeta) fn from_bytes(
    b: &[u8]
) -> Self
[src]

pub(in rmeta) fn write_to_bytes(
    self,
    b: &mut [u8]
)
[src]

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

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.

pub(in rmeta) fn write_to_bytes_at(
    self,
    b: &mut [u8],
    i: usize
)
[src]

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