Struct U128

Source
#[repr(C)]
pub struct U128<E>(/* private fields */);
Expand description

A type that wraps a byte array to be decoded into a u128.

The generic parameter represents the endianness used to decode the wrapped value. In case the value is expected to have fixed endianness, either BigEndian or LittleEndian types should be used, otherwise the Endian type.

Implementations§

Source§

impl<E> U128<E>

Source

pub const fn from_bytes(bytes: [u8; 16]) -> Self

Converts a byte array into a U128.

Source

pub const fn into_bytes(self) -> [u8; 16]

Converts a U128 into a byte array.

Source§

impl U128<Endian>

Source

pub const fn new_with_endian(value: u128, endian: Endian) -> Self

Constructs a U128 wrapper type from a u128 value using the specified endianness.

Source

pub const fn get_with_endian(self, endian: Endian) -> u128

Extracts a u128 value from a U128 wrapper using the specified endianness.

Source§

impl<E: FixedEndian> U128<E>

Source

pub const fn new(value: u128) -> Self

Constructs a U128 wrapper type from a u128 value using the type’s fixed endianness.

Source

pub const fn get(self) -> u128

Extracts a u128 value from a U128 wrapper using the type’s fixed endianness.

Trait Implementations§

Source§

impl<E: Clone> Clone for U128<E>

Source§

fn clone(&self) -> U128<E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for U128<BigEndian>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debug for U128<Endian>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debug for U128<LittleEndian>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E> Default for U128<E>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<E: FixedEndian> From<u128> for U128<E>

Source§

fn from(value: u128) -> Self

Converts to this type from the input type.
Source§

impl<E: Hash> Hash for U128<E>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<E: PartialEq> PartialEq for U128<E>

Source§

fn eq(&self, other: &U128<E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E> ReprByteSlice for U128<E>

Source§

fn from_byte_slice(s: &[u8]) -> Result<&Self, UnalignedSizeError>

Transmutes an immutable byte slice reference into an immutable Self reference. Read more
Source§

fn from_byte_slice_mut(s: &mut [u8]) -> Result<&mut Self, UnalignedSizeError>

Transmutes a mutable byte slice reference into a mutable Self reference. Read more
Source§

fn as_byte_slice(&self) -> &[u8]

Transmutes an immutable reference to self into an immutable reference to a byte slice.
Source§

fn as_byte_slice_mut(&mut self) -> &mut [u8]

Transmutes a mutable reference to self into a mutable reference to a byte slice.
Source§

fn slice_from_byte_slice(s: &[u8]) -> Result<&[Self], UnalignedSizeError>

Transmutes an immutable byte slice reference into an immutable to a slice of Self. Read more
Source§

fn slice_from_byte_slice_mut( s: &mut [u8], ) -> Result<&mut [Self], UnalignedSizeError>

Transmutes a mutable byte slice reference into a mutable to a slice of Self. Read more
Source§

fn slice_as_byte_slice(slice: &[Self]) -> Result<&[u8], SliceSizeOverflowError>

Transmutes an immutable reference to a slice of Self into an immutable reference to a byte slice. Read more
Source§

fn slice_as_byte_slice_mut( slice: &mut [Self], ) -> Result<&mut [u8], SliceSizeOverflowError>

Transmutes a mutable reference to a slice of Self into a mutable reference to a byte slice. Read more
Source§

fn uninit_slice_from_byte_slice( s: &[MaybeUninit<u8>], ) -> Result<&[MaybeUninit<Self>], UnalignedSizeError>

Transmutes an immutable reference to a slice of MaybeUninit<u8> into an immutable reference to a slice of MaybeUninit<Self>. Read more
Source§

fn uninit_slice_from_byte_slice_mut( s: &mut [MaybeUninit<u8>], ) -> Result<&mut [MaybeUninit<Self>], UnalignedSizeError>

Transmutes a mutable reference to a slice of MaybeUninit<u8> into a mutable reference to a slice of MaybeUninit<Self>. Read more
Source§

fn uninit_slice_as_byte_slice( slice: &[MaybeUninit<Self>], ) -> Result<&[MaybeUninit<u8>], SliceSizeOverflowError>

Transmutes an immutable reference to a slice of MaybeUninit<Self> into an immutable reference to a slice of MaybeUninit<u8>. Read more
Source§

fn uninit_slice_as_byte_slice_mut( slice: &mut [MaybeUninit<Self>], ) -> Result<&mut [MaybeUninit<u8>], SliceSizeOverflowError>

Transmutes a mutable reference to a slice of MaybeUninit<u8> into a mutable reference to a slice of MaybeUninit<Self>. Read more
Source§

impl<E: Copy> Copy for U128<E>

Source§

impl<E: Eq> Eq for U128<E>

Source§

impl<E> StructuralPartialEq for U128<E>

Auto Trait Implementations§

§

impl<E> Freeze for U128<E>

§

impl<E> RefUnwindSafe for U128<E>
where E: RefUnwindSafe,

§

impl<E> Send for U128<E>
where E: Send,

§

impl<E> Sync for U128<E>
where E: Sync,

§

impl<E> Unpin for U128<E>
where E: Unpin,

§

impl<E> UnwindSafe for U128<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.