[−][src]Trait rustc_metadata::rmeta::table::FixedSizeEncoding
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
Loading content...Required methods
pub(in rmeta) fn from_bytes(
b: &[u8]
) -> Self[src]
b: &[u8]
) -> Self
pub(in rmeta) fn write_to_bytes(
self,
b: &mut [u8]
)[src]
self,
b: &mut [u8]
)
pub(in rmeta) fn maybe_read_from_bytes_at(
b: &[u8],
i: usize
) -> Option<Self>[src]
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.
pub(in rmeta) fn write_to_bytes_at(
self,
b: &mut [u8],
i: usize
)[src]
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.
Implementations on Foreign Types
impl FixedSizeEncoding for u32[src]
pub(in rmeta) const BYTE_LEN: usize[src]
pub(in rmeta) fn maybe_read_from_bytes_at(
b: &[u8],
i: usize
) -> Option<Self>[src]
b: &[u8],
i: usize
) -> Option<Self>
pub(in rmeta) fn write_to_bytes_at(
self,
b: &mut [u8],
i: usize
)[src]
self,
b: &mut [u8],
i: usize
)
pub(in rmeta) fn from_bytes(
b: &[u8]
) -> Self[src]
b: &[u8]
) -> Self
pub(in rmeta) fn write_to_bytes(
self,
b: &mut [u8]
)[src]
self,
b: &mut [u8]
)
impl<T> FixedSizeEncoding for Option<Lazy<T>>[src]
pub(in rmeta) const BYTE_LEN: usize[src]
pub(in rmeta) fn maybe_read_from_bytes_at(
b: &[u8],
i: usize
) -> Option<Self>[src]
b: &[u8],
i: usize
) -> Option<Self>
pub(in rmeta) fn write_to_bytes_at(
self,
b: &mut [u8],
i: usize
)[src]
self,
b: &mut [u8],
i: usize
)
pub(in rmeta) fn from_bytes(
b: &[u8]
) -> Self[src]
b: &[u8]
) -> Self
pub(in rmeta) fn write_to_bytes(
self,
b: &mut [u8]
)[src]
self,
b: &mut [u8]
)
impl<T> FixedSizeEncoding for Option<Lazy<[T]>>[src]
pub(in rmeta) const BYTE_LEN: usize[src]
pub(in rmeta) fn maybe_read_from_bytes_at(
b: &[u8],
i: usize
) -> Option<Self>[src]
b: &[u8],
i: usize
) -> Option<Self>
pub(in rmeta) fn write_to_bytes_at(
self,
b: &mut [u8],
i: usize
)[src]
self,
b: &mut [u8],
i: usize
)
pub(in rmeta) fn from_bytes(
b: &[u8]
) -> Self[src]
b: &[u8]
) -> Self
pub(in rmeta) fn write_to_bytes(
self,
b: &mut [u8]
)[src]
self,
b: &mut [u8]
)