Trait zerovec::ule::AsULE [−][src]
pub trait AsULE { type ULE: ULE; fn as_unaligned(&self) -> Self::ULE; fn from_unaligned(unaligned: &Self::ULE) -> Self; }
Expand description
A trait for any type that has a 1:1 mapping with an unaligned little-endian (ULE) type.
Associated Types
type ULE: ULE
[src]
Expand description
The ULE type corresponding to Self
.
Types having infallible conversions from all bit values (Plain Old Data) can use
PlainOldULE
with the desired width; for example, u32
uses PlainOldULE<4>
.
Types that are not well-defined for all bit values should implement a custom ULE.
Required methods
fn as_unaligned(&self) -> Self::ULE
[src]
Expand description
Converts from &Self
to Self::ULE
.
This function may involve byte order swapping (native-endian to little-endian).
For best performance, mark your implementation of this function #[inline]
.
fn from_unaligned(unaligned: &Self::ULE) -> Self
[src]
Expand description
Converts from &Self::ULE
to Self
.
This function may involve byte order swapping (little-endian to native-endian).
For best performance, mark your implementation of this function #[inline]
.
Safety
This function is infallible because bit validation should have occured when Self::ULE
was first constructed. An implementation may therefore involve an unsafe{}
block, like
from_bytes_unchecked()
.
Implementations on Foreign Types
impl AsULE for char
[src]
impl AsULE for char
[src]type ULE = CharULE
fn as_unaligned(&self) -> Self::ULE
[src]
fn from_unaligned(unaligned: &Self::ULE) -> Self
[src]
impl AsULE for u16
[src]
impl AsULE for u16
[src]type ULE = PlainOldULE<2>
fn as_unaligned(&self) -> Self::ULE
[src]
fn from_unaligned(unaligned: &Self::ULE) -> Self
[src]
impl AsULE for u32
[src]
impl AsULE for u32
[src]type ULE = PlainOldULE<4>
fn as_unaligned(&self) -> Self::ULE
[src]
fn from_unaligned(unaligned: &Self::ULE) -> Self
[src]
impl AsULE for u64
[src]
impl AsULE for u64
[src]type ULE = PlainOldULE<8>
fn as_unaligned(&self) -> Self::ULE
[src]
fn from_unaligned(unaligned: &Self::ULE) -> Self
[src]
impl AsULE for u128
[src]
impl AsULE for u128
[src]type ULE = PlainOldULE<16>
fn as_unaligned(&self) -> Self::ULE
[src]
fn from_unaligned(unaligned: &Self::ULE) -> Self
[src]
impl AsULE for i16
[src]
impl AsULE for i16
[src]type ULE = PlainOldULE<2>
fn as_unaligned(&self) -> Self::ULE
[src]
fn from_unaligned(unaligned: &Self::ULE) -> Self
[src]
impl AsULE for i32
[src]
impl AsULE for i32
[src]type ULE = PlainOldULE<4>
fn as_unaligned(&self) -> Self::ULE
[src]
fn from_unaligned(unaligned: &Self::ULE) -> Self
[src]
impl AsULE for i64
[src]
impl AsULE for i64
[src]type ULE = PlainOldULE<8>
fn as_unaligned(&self) -> Self::ULE
[src]
fn from_unaligned(unaligned: &Self::ULE) -> Self
[src]
impl AsULE for i128
[src]
impl AsULE for i128
[src]