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

§

type ULE = bool

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for char

§

type ULE = CharULE

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for f32

§

type ULE = RawBytesULE<4>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for f64

§

type ULE = RawBytesULE<8>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for i8

§

type ULE = i8

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for i16

§

type ULE = RawBytesULE<2>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for i32

§

type ULE = RawBytesULE<4>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for i64

§

type ULE = RawBytesULE<8>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for i128

§

type ULE = RawBytesULE<16>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for u8

§

type ULE = u8

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for u16

§

type ULE = RawBytesULE<2>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for u32

§

type ULE = RawBytesULE<4>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for u64

§

type ULE = RawBytesULE<8>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for u128

§

type ULE = RawBytesULE<16>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for NonZeroI8

§

type ULE = NonZero<u8>

source§

fn to_unaligned(self) -> Self::ULE

source§

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

source§

impl AsULE for NonZeroU8

§

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)

§

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)

§

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)

§

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)

§

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)

§

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>

§

type ULE = OptionULE<<T as AsULE>::ULE>

source§

fn to_unaligned(self) -> OptionULE<T::ULE>

source§

fn from_unaligned(other: OptionULE<T::ULE>) -> Self

source§

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

§

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

§

type ULE = RawBytesULE<3>

source§

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

§

type ULE = NichedOptionULE<<U as AsULE>::ULE, N>