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

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

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.

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.

Constructs a new value from bytes which are already in the endianness O.

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

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.

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

Gets the bytes of this value. Read more
Gets the bytes of this value mutably. Read more
Writes a copy of self to bytes. Read more
Writes a copy of self to the prefix of bytes. Read more
Writes a copy of self to the suffix of bytes. Read more
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Formats the value using the given formatter.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Reads a copy of Self from bytes. Read more
Reads a copy of Self from the prefix of bytes. Read more
Reads a copy of Self from the suffix of bytes. Read more
Creates an instance of Self from zeroed bytes.
Creates a Box<Self> from zeroed bytes. Read more
Creates a Box<[Self]> (a boxed slice) from zeroed bytes. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
Formats the value using the given formatter.
Formats the value using the given formatter.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.