Enum byteordered::Endianness
source · pub enum Endianness {
Little,
Big,
}
Expand description
Enumerate for materializing the two kinds of machine byte order supported by Rust.
Variants§
Implementations§
source§impl Endianness
impl Endianness
sourcepub fn native() -> Self
pub fn native() -> Self
Obtains this system’s native endianness.
On this platform, the function returns Endianness::Little
.
sourcepub fn le_iif(e: bool) -> Self
pub fn le_iif(e: bool) -> Self
Obtains Little Endian if and only if the given value is true
.
Examples
assert_eq!(Endianness::le_iif(2 + 2 == 4), Endianness::Little);
assert_eq!(Endianness::le_iif(2 + 2 >= 5), Endianness::Big);
sourcepub fn be_iif(e: bool) -> Self
pub fn be_iif(e: bool) -> Self
Obtains Big Endian if and only if the given value is true
.
Examples
assert_eq!(Endianness::be_iif(2 + 2 == 4), Endianness::Big);
assert_eq!(Endianness::be_iif(2 + 2 >= 5), Endianness::Little);
sourcepub fn to_opposite(self) -> Self
pub fn to_opposite(self) -> Self
Obtains the opposite endianness: Little Endian returns Big Endian and vice versa.
Trait Implementations§
source§impl Clone for Endianness
impl Clone for Endianness
source§fn clone(&self) -> Endianness
fn clone(&self) -> Endianness
Returns a copy of the value. Read more
1.0.0 · 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 Endian for Endianness
impl Endian for Endianness
source§fn read_i16<S>(&self, src: S) -> IoResult<i16>where
S: Read,
fn read_i16<S>(&self, src: S) -> IoResult<i16>where
S: Read,
Reads a signed 16 bit integer from the given reader. Read more
source§fn read_u16<S>(&self, src: S) -> IoResult<u16>where
S: Read,
fn read_u16<S>(&self, src: S) -> IoResult<u16>where
S: Read,
Reads an unsigned 16 bit integer from the given reader. Read more
source§fn read_i32<S>(&self, src: S) -> IoResult<i32>where
S: Read,
fn read_i32<S>(&self, src: S) -> IoResult<i32>where
S: Read,
Reads a signed 32 bit integer from the given reader. Read more
source§fn read_u32<S>(&self, src: S) -> IoResult<u32>where
S: Read,
fn read_u32<S>(&self, src: S) -> IoResult<u32>where
S: Read,
Reads an unsigned 32 bit integer from the given reader. Read more
source§fn read_i64<S>(&self, src: S) -> IoResult<i64>where
S: Read,
fn read_i64<S>(&self, src: S) -> IoResult<i64>where
S: Read,
Reads a signed 64 bit integer from the given reader. Read more
source§fn read_u64<S>(&self, src: S) -> IoResult<u64>where
S: Read,
fn read_u64<S>(&self, src: S) -> IoResult<u64>where
S: Read,
Reads an unsigned 16 bit integer from the given reader. Read more
source§fn read_f32<S>(&self, src: S) -> IoResult<f32>where
S: Read,
fn read_f32<S>(&self, src: S) -> IoResult<f32>where
S: Read,
Reads a IEEE754 single-precision (4 bytes) floating point number from
the given reader. Read more
source§fn read_f64<S>(&self, src: S) -> IoResult<f64>where
S: Read,
fn read_f64<S>(&self, src: S) -> IoResult<f64>where
S: Read,
Reads a IEEE754 double-precision (8 bytes) floating point number from
the given reader. Read more
source§fn write_i16<S>(&self, src: S, v: i16) -> IoResult<()>where
S: Write,
fn write_i16<S>(&self, src: S, v: i16) -> IoResult<()>where
S: Write,
Writes a signed 16 bit integer to the given writer. Read more
source§fn write_u16<S>(&self, src: S, v: u16) -> IoResult<()>where
S: Write,
fn write_u16<S>(&self, src: S, v: u16) -> IoResult<()>where
S: Write,
Writes an unsigned 16 bit integer to the given writer. Read more
source§fn write_i32<S>(&self, src: S, v: i32) -> IoResult<()>where
S: Write,
fn write_i32<S>(&self, src: S, v: i32) -> IoResult<()>where
S: Write,
Writes a signed 32 bit integer to the given writer. Read more
source§fn write_u32<S>(&self, src: S, v: u32) -> IoResult<()>where
S: Write,
fn write_u32<S>(&self, src: S, v: u32) -> IoResult<()>where
S: Write,
Writes an unsigned 32 bit integer to the given writer. Read more
source§fn write_i64<S>(&self, src: S, v: i64) -> IoResult<()>where
S: Write,
fn write_i64<S>(&self, src: S, v: i64) -> IoResult<()>where
S: Write,
Writes a signed 64 bit integer to the given writer. Read more
source§fn write_u64<S>(&self, src: S, v: u64) -> IoResult<()>where
S: Write,
fn write_u64<S>(&self, src: S, v: u64) -> IoResult<()>where
S: Write,
Writes an unsigned 64 bit integer to the given writer. Read more
source§impl From<StaticEndianness<BigEndian>> for Endianness
impl From<StaticEndianness<BigEndian>> for Endianness
source§fn from(_: StaticEndianness<BigEndian>) -> Self
fn from(_: StaticEndianness<BigEndian>) -> Self
Converts to this type from the input type.
source§impl From<StaticEndianness<LittleEndian>> for Endianness
impl From<StaticEndianness<LittleEndian>> for Endianness
source§fn from(_: StaticEndianness<LittleEndian>) -> Self
fn from(_: StaticEndianness<LittleEndian>) -> Self
Converts to this type from the input type.
source§impl Hash for Endianness
impl Hash for Endianness
source§impl Ord for Endianness
impl Ord for Endianness
source§fn cmp(&self, other: &Endianness) -> Ordering
fn cmp(&self, other: &Endianness) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<Endianness> for Endianness
impl PartialEq<Endianness> for Endianness
source§fn eq(&self, other: &Endianness) -> bool
fn eq(&self, other: &Endianness) -> bool
source§impl PartialOrd<Endianness> for Endianness
impl PartialOrd<Endianness> for Endianness
source§fn partial_cmp(&self, other: &Endianness) -> Option<Ordering>
fn partial_cmp(&self, other: &Endianness) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more