Trait zerovec::ule::AsULE

source ·
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§

source

type ULE: ULE

The ULE type corresponding to Self.

Types having infallible conversions from all bit values (Plain Old Data) can use RawBytesULE with the desired width; for example, u32 uses RawBytesULE<4>.

Types that are not well-defined for all bit values should implement a custom ULE.

Required Methods§

source

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].

source

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().

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl AsULE for bool

source§

type ULE = bool

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for char

source§

type ULE = CharULE

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for f32

source§

type ULE = RawBytesULE<4>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for f64

source§

type ULE = RawBytesULE<8>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for i8

source§

type ULE = i8

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for i16

source§

type ULE = RawBytesULE<2>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for i32

source§

type ULE = RawBytesULE<4>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for i64

source§

type ULE = RawBytesULE<8>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for i128

source§

type ULE = RawBytesULE<16>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for u8

source§

type ULE = u8

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for u16

source§

type ULE = RawBytesULE<2>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for u32

source§

type ULE = RawBytesULE<4>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for u64

source§

type ULE = RawBytesULE<8>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for u128

source§

type ULE = RawBytesULE<16>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for NonZeroI8

source§

type ULE = NonZero<u8>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl AsULE for NonZeroU8

source§

type ULE = NonZero<u8>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl<A: AsULE, B: AsULE> AsULE for (A, B)

source§

type ULE = Tuple2ULE<<A as AsULE>::ULE, <B as AsULE>::ULE>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl<A: AsULE, B: AsULE, C: AsULE> AsULE for (A, B, C)

source§

type ULE = Tuple3ULE<<A as AsULE>::ULE, <B as AsULE>::ULE, <C as AsULE>::ULE>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl<A: AsULE, B: AsULE, C: AsULE, D: AsULE> AsULE for (A, B, C, D)

source§

type ULE = Tuple4ULE<<A as AsULE>::ULE, <B as AsULE>::ULE, <C as AsULE>::ULE, <D as AsULE>::ULE>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl<A: AsULE, B: AsULE, C: AsULE, D: AsULE, E: AsULE> AsULE for (A, B, C, D, E)

source§

type ULE = Tuple5ULE<<A as AsULE>::ULE, <B as AsULE>::ULE, <C as AsULE>::ULE, <D as AsULE>::ULE, <E as AsULE>::ULE>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl<A: AsULE, B: AsULE, C: AsULE, D: AsULE, E: AsULE, F: AsULE> AsULE for (A, B, C, D, E, F)

source§

type ULE = Tuple6ULE<<A as AsULE>::ULE, <B as AsULE>::ULE, <C as AsULE>::ULE, <D as AsULE>::ULE, <E as AsULE>::ULE, <F as AsULE>::ULE>

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

source§

impl<T: AsULE> AsULE for Option<T>

source§

impl<T: AsULE, const N: usize> AsULE for [T; N]

source§

type ULE = [<T as AsULE>::ULE; N]

source§

fn to_unaligned(self) -> Self::ULE

source§

fn from_unaligned(unaligned: Self::ULE) -> Self

Implementors§

source§

impl AsULE for UnvalidatedChar

source§

impl<U: AsULE, const N: usize> AsULE for NichedOption<U, N>
where U::ULE: NicheBytes<N>,