pub trait AsULE: Copy {
type ULE: ULE;
// Required methods
fn to_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.
If you need to implement this trait, consider using #[make_ule]
instead.
Required Associated Types§
Required Methods§
Sourcefn to_unaligned(self) -> Self::ULE
fn to_unaligned(self) -> Self::ULE
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]
.
Sourcefn from_unaligned(unaligned: Self::ULE) -> Self
fn from_unaligned(unaligned: Self::ULE) -> Self
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 occurred when Self::ULE
was first constructed. An implementation may therefore involve an unsafe{}
block, like
from_bytes_unchecked()
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.