pub enum Endianness {
Little,
Big,
}Expand description
Which byte order a binary stream uses.
Variants§
Little
Least-significant byte first (x86/arm default).
Big
Most-significant byte first (network order, big-endian).
Implementations§
Source§impl Endianness
impl Endianness
Sourcepub fn u32_to_bytes(self, v: u32) -> [u8; 4]
pub fn u32_to_bytes(self, v: u32) -> [u8; 4]
Convert a u32 to bytes in this byte order.
Sourcepub fn u32_from_bytes(self, b: [u8; 4]) -> u32
pub fn u32_from_bytes(self, b: [u8; 4]) -> u32
Convert a u32 from bytes in this byte order.
Sourcepub fn f64_to_bytes(self, v: f64) -> [u8; 8]
pub fn f64_to_bytes(self, v: f64) -> [u8; 8]
Convert a f64 to bytes in this byte order.
Sourcepub fn f64_from_bytes(self, b: [u8; 8]) -> f64
pub fn f64_from_bytes(self, b: [u8; 8]) -> f64
Convert a f64 from bytes in this byte order.
Sourcepub fn u32_to_native(self, v: u32) -> u32
pub fn u32_to_native(self, v: u32) -> u32
Swap bytes of a u32 from this endianness to native order.
Trait Implementations§
Source§impl Clone for Endianness
impl Clone for Endianness
Source§fn clone(&self) -> Endianness
fn clone(&self) -> Endianness
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Endianness
impl Debug for Endianness
Source§impl PartialEq for Endianness
impl PartialEq for Endianness
Source§fn eq(&self, other: &Endianness) -> bool
fn eq(&self, other: &Endianness) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for Endianness
impl Eq for Endianness
impl StructuralPartialEq for Endianness
Auto Trait Implementations§
impl Freeze for Endianness
impl RefUnwindSafe for Endianness
impl Send for Endianness
impl Sync for Endianness
impl Unpin for Endianness
impl UnsafeUnpin for Endianness
impl UnwindSafe for Endianness
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.