pub trait Endianness {
fn is_le() -> bool;
fn is_be() -> bool;
}
#[derive(Debug)]
pub struct BigEndian;
#[derive(Debug)]
pub struct LittleEndian;
macro_rules! impl_endianness {
($type:ty, $le:expr) => {
impl Endianness for $type {
#[inline(always)]
fn is_le() -> bool {
$le
}
#[inline(always)]
fn is_be() -> bool {
!$le
}
}
};
}
impl_endianness!(BigEndian, false);
impl_endianness!(LittleEndian, true);