[][src]Struct zerocopy::byteorder::I128

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

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

I128 is like the native i128 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.

An I128 can be constructed using the new method, and its contained value can be obtained as a native i128 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 I128 has endianness O and that, b) the layout of i128 has the platform's native endianness.

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

Methods

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

pub const ZERO: I128<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 fn new(n: i128) -> I128<O>[src]

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

pub fn get(self) -> i128[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: i128)[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> FromBytes for I128<O> where
    PhantomData<O>: FromBytes
[src]

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

fn as_bytes(&self) -> &[u8][src]

Get the bytes of this value. Read more

fn as_bytes_mut(&mut self) -> &mut [u8] where
    Self: FromBytes
[src]

Get the bytes of this value mutably. Read more

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

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

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

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

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

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

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

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

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

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

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

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

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

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

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

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

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

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

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

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

Auto Trait Implementations

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

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

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

Blanket Implementations

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> Into<U> for T where
    U: From<T>, 
[src]

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

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.

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

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

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