Struct zerocopy::byteorder::U32[][src]

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

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

U32 is like the native u32 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 U32 can be constructed using the new method, and its contained value can be obtained as a native u32 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 U32 has endianness O and that, b) the layout of u32 has the platform’s native endianness.

U32 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

Performs the conversion.

Performs the conversion.

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

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

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 !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.