Struct format_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, otherwise the Endian type.

Implementations§

source§

impl<E> U128<E>

source

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

Converts a byte array into a U128.

source§

impl<E> U128<E>

source

pub fn slice_as_byte_slice(slice: &[Self]) -> &[u8]

Converts an immutable slice of U128 into an immutable byte slice.

source

pub fn slice_as_byte_slice_mut(slice: &mut [Self]) -> &mut [u8]

Converts a mutable slice of U128 into a mutable byte slice.

source§

impl U128<Endian>

source

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

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

source

pub 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 fn new(value: u128) -> Self

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

source

pub 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 copy 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<E: Debug> Debug for U128<E>

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> FromByteSlice for U128<E>

source§

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

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, InvalidSizeError>

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

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

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], InvalidSizeError>

Transmutes a mutable byte slice reference into a mutable to a slice of Self. Read more
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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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> 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>,

§

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>,

§

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.