pub enum Endian {
Big,
Little,
}
Expand description
An Enum for handling byte order.
Variants§
Implementations§
Source§impl Endian
impl Endian
Sourcepub const NATIVE: Self = NATIVE_ENDIAN
pub const NATIVE: Self = NATIVE_ENDIAN
The byte order of the current target.
§Examples
use lib_endian::Endian;
const NE: Endian = Endian::NATIVE;
Sourcepub const fn is(self, other: Self) -> bool
pub const fn is(self, other: Self) -> bool
Tests for self
and other
values to be equal.
§Examples
use lib_endian::Endian;
const BE: Endian = Endian::Big;
const IS_EQUAL: bool = BE.is(Endian::Big);
assert!(IS_EQUAL);
You can also use ==
out Constant Expressions:
use lib_endian::Endian;
let be = Endian::Big;
let is_equal = be == Endian::Big;
assert!(is_equal);
Sourcepub const fn reverse(self) -> Self
pub const fn reverse(self) -> Self
Returns a new Endian
value which is different from self
.
§Examples
use lib_endian::Endian;
const BE: Endian = Endian::Little.reverse();
const IS_EQUAL: bool = BE.reverse().is(Endian::Little);
assert!(IS_EQUAL);
You can also use !
out Constant Expressions:
use lib_endian::Endian;
let be = !Endian::Little;
let is_equal = !be == Endian::Little;
assert!(is_equal);
Sourcepub const fn native_or_reversed(reverse: bool) -> Self
pub const fn native_or_reversed(reverse: bool) -> Self
Returns Endian::native()
if reverse
is true,
otherwise returns Endian::native().reverse()
.
§Examples
use lib_endian::Endian;
const REVERSE: bool = true;
const NE_REV: Endian = Endian::native_or_reversed(REVERSE);
assert_eq!(NE_REV, Endian::NATIVE.reverse());
const NE: Endian = Endian::native_or_reversed(!REVERSE);
assert_eq!(NE, Endian::NATIVE);
Trait Implementations§
impl Copy for Endian
impl Eq for Endian
impl StructuralPartialEq for Endian
Auto Trait Implementations§
impl Freeze for Endian
impl RefUnwindSafe for Endian
impl Send for Endian
impl Sync for Endian
impl Unpin for Endian
impl UnwindSafe for Endian
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