Trait zerovec::ule::ULE [−][src]
pub trait ULE where
Self: Sized, { type Error; fn parse_byte_slice(bytes: &[u8]) -> Result<&[Self], Self::Error>; fn as_byte_slice(slice: &[Self]) -> &[u8]; }
Fixed-width, byte-aligned data that can be cast to and from a little-endian byte slice.
“ULE” stands for “Unaligned little-endian”
Associated Types
Loading content...Required methods
fn parse_byte_slice(bytes: &[u8]) -> Result<&[Self], Self::Error>
[src]
Parses a byte slice, &[u8]
, and return it as &[Self]
with the same lifetime.
If Self
is not well-defined for all possible bit values, the bytes should be validated,
and Self::Error
should be returned if they are not valid.
Safety
Implementations of this method may involve unsafe{}
blocks to cast the pointer to the
correct type. It is up to the implementation to reason about the safety. Keep in mind that
&[Self]
and &[u8]
may have different lengths.
fn as_byte_slice(slice: &[Self]) -> &[u8]
[src]
Given &[Self]
, returns a &[u8]
with the same lifetime.
Safety
In most cases, the implementation of this function should involve re-casting the pointer.
It is up to the implementation to reason about the safety. Keep in mind that &[Self]
and
&[u8]
may have different lengths.