Struct zerocopy::byteorder::U128[][src]

#[repr(transparent)]
pub struct U128<O: ByteOrder>(_, _);

A 128-bit unsigned integer stored in O byte order.

U128 is like the native u128 type with two major differences: First, it has no alignment requirement (its alignment is 1). Second, the endianness of its memory layout is given by the type parameter O.

A U128 can be constructed using the new method, and its contained value can be obtained as a native u128 using the get method, or updated in place with the set method. In all cases, if the endianness O is not the same as the endianness of the current platform, an endianness swap will be performed in order to uphold the invariants that a) the layout of U128 has endianness O and that, b) the layout of u128 has the platform’s native endianness.

U128 implements FromBytes, AsBytes, and Unaligned, making it useful for parsing and serialization. See the module documentation for an example of how it can be used for parsing UDP packets.

Implementations

impl<O: ByteOrder> U128<O>[src]

pub const ZERO: U128<O>[src]

The value zero.

This constant should be preferred to constructing a new value using new, as new may perform an endianness swap depending on the endianness and platform.

pub const MAX_VALUE: U128<O>[src]

The maximum value.

This constant should be preferred to constructing a new value using new, as new may perform an endianness swap depending on the endianness O and the endianness of the platform.

pub fn new(n: u128) -> U128<O>[src]

Constructs a new value, possibly performing an endianness swap to guarantee that the returned value has endianness O.

pub fn get(self) -> u128[src]

Returns the value as a primitive type, possibly performing an endianness swap to guarantee that the return value has the endianness of the native platform.

pub fn set(&mut self, n: u128)[src]

Updates the value in place as a primitive type, possibly performing an endianness swap to guarantee that the stored value has the endianness O.

Trait Implementations

impl<O: ByteOrder> AsBytes for U128<O>[src]

impl<O: ByteOrder> AsMut<[u8; 16]> for U128<O>[src]

impl<O: ByteOrder> AsRef<[u8; 16]> for U128<O>[src]

impl<O: ByteOrder> Binary for U128<O>[src]

impl<O: Clone + ByteOrder> Clone for U128<O>[src]

impl<O: Copy + ByteOrder> Copy for U128<O>[src]

impl<O: ByteOrder> Debug for U128<O>[src]

impl<O: Default + ByteOrder> Default for U128<O>[src]

impl<O: ByteOrder> Display for U128<O>[src]

impl<O: Eq + ByteOrder> Eq for U128<O>[src]

impl<O: ByteOrder> From<[u8; 16]> for U128<O>[src]

impl<O: ByteOrder, P: ByteOrder> From<U16<O>> for U128<P>[src]

impl<O: ByteOrder, P: ByteOrder> From<U32<O>> for U128<P>[src]

impl<O: ByteOrder, P: ByteOrder> From<U64<O>> for U128<P>[src]

impl<O: ByteOrder> From<u128> for U128<O>[src]

impl<O: ByteOrder> FromBytes for U128<O> where
    PhantomData<O>: FromBytes
[src]

impl<O: Hash + ByteOrder> Hash for U128<O>[src]

impl<O: ByteOrder> LowerHex for U128<O>[src]

impl<O: ByteOrder> Octal for U128<O>[src]

impl<O: ByteOrder> PartialEq<[u8; 16]> for U128<O>[src]

impl<O: PartialEq + ByteOrder> PartialEq<U128<O>> for U128<O>[src]

impl<O: ByteOrder> StructuralEq for U128<O>[src]

impl<O: ByteOrder> StructuralPartialEq for U128<O>[src]

impl<O: ByteOrder, P: ByteOrder> TryFrom<U128<P>> for U16<O>[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl<O: ByteOrder, P: ByteOrder> TryFrom<U128<P>> for U32<O>[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl<O: ByteOrder, P: ByteOrder> TryFrom<U128<P>> for U64<O>[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl<O: ByteOrder> Unaligned for U128<O> where
    PhantomData<O>: Unaligned
[src]

impl<O: ByteOrder> UpperHex for U128<O>[src]

Auto Trait Implementations

impl<O> Send for U128<O> where
    O: Send

impl<O> Sync for U128<O> where
    O: Sync

impl<O> Unpin for U128<O> where
    O: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.