zerovec::ule

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

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.

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

Source§

type ULE = ()

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<U: AsULE, const N: usize> AsULE for NichedOption<U, N>
where U::ULE: NicheBytes<N>,

impl AsULE for PackedHijriYearInfo

impl AsULE for EraStartDate

impl AsULE for MonthCode

impl AsULE for CaseMapData

impl AsULE for ExceptionBits

impl AsULE for SlotPresence

impl AsULE for Day

impl AsULE for DayPeriod

impl AsULE for DecimalSecond

impl AsULE for FieldLength

impl AsULE for FieldSymbol

impl AsULE for Hour

impl AsULE for Month

impl AsULE for Second

impl AsULE for TimeZone

impl AsULE for Weekday

impl AsULE for Year

impl AsULE for GenericPatternItem

impl AsULE for PatternItem

impl AsULE for Field

impl AsULE for PatternMetadata

impl AsULE for Count

impl AsULE for PatternSelection

impl AsULE for CompactCount

impl AsULE for PatternKey

impl AsULE for CompoundCount

impl AsULE for Base

impl AsULE for Exactness

impl AsULE for Sign

impl AsULE for CurrencyPatternConfig

impl AsULE for SiPrefix

impl AsULE for SingleUnit

impl AsULE for Subtag

impl AsULE for Key

impl AsULE for Attribute

impl AsULE for Key

impl AsULE for SubdivisionSuffix

impl AsULE for Language

impl AsULE for Region

impl AsULE for Script

impl AsULE for Subtag

impl AsULE for Variant

impl AsULE for PluralCategory

impl AsULE for RawPluralCategory

impl AsULE for UnvalidatedPluralRange

impl AsULE for GeneralCategory

impl AsULE for BidiClass

impl AsULE for BidiMirroringGlyph

impl AsULE for EastAsianWidth

impl AsULE for GeneralCategoryGroup

impl AsULE for GraphemeClusterBreak

impl AsULE for HangulSyllableType

impl AsULE for IndicSyllabicCategory

impl AsULE for JoiningType

impl AsULE for LineBreak

impl AsULE for Script

impl AsULE for SentenceBreak

impl AsULE for WordBreak

impl AsULE for DataMarkerIdHash

impl AsULE for WordType

impl AsULE for BreakState

impl AsULE for TimeZoneVariant

impl AsULE for MinutesSinceEpoch

impl AsULE for TimeZone

impl AsULE for PotentialCodePoint

impl<const N: usize> AsULE for TinyAsciiStr<N>

impl<const N: usize> AsULE for UnvalidatedTinyAsciiStr<N>