Function ref_from_prefix_suffix

Source
pub(crate) fn ref_from_prefix_suffix<T: FromBytes + KnownLayout + Immutable + ?Sized>(
    source: &[u8],
    meta: Option<T::PointerMetadata>,
    cast_type: CastType,
) -> Result<(&T, &[u8]), CastError<&[u8], T>>
Expand description

Interprets the given affix of the given bytes as a &Self.

This method computes the largest possible size of Self that can fit in the prefix or suffix bytes of source, then attempts to return both a reference to those bytes interpreted as a Self, and a reference to the excess bytes. If there are insufficient bytes, or if that affix of source is not appropriately aligned, this returns Err.