hff_core/endian.rs
1/// The byte order trait.
2pub use byteorder::ByteOrder;
3/// Little Endian.
4pub type LE = byteorder::LittleEndian;
5/// Big Endian.
6pub type BE = byteorder::BigEndian;
7/// Native Endian.
8pub type NE = byteorder::NativeEndian;
9/// Opposing Endian.
10#[cfg(target_endian = "little")]
11pub type OP = byteorder::BigEndian;
12#[cfg(target_endian = "big")]
13pub type OP = byteorder::LittleEndian;
14
15// These are runtime endian detection items since byteorder
16// has had an outstanding ticket to add such things for several
17// years and as such seems they will not be added.
18
19// It is needed here because we 'try' to work with local endian
20// but have to know how to flip things at runtime when dealing
21// with non-native endian.
22
23/// Runtime endianess values.
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
25pub enum Endian {
26 /// Little endian.
27 Little,
28 /// Big endian.
29 Big,
30}
31
32// Runtime native endian.
33
34/// The runtime native endian.
35#[cfg(target_endian = "little")]
36pub const NATIVE_ENDIAN: Endian = Endian::Little;
37/// The runtime native endian.
38#[cfg(target_endian = "big")]
39pub const NATIVE_ENDIAN: Endian = Endian::Big;
40
41// Runtime opposiing endian.
42
43/// The runtime opposing endian.
44#[cfg(target_endian = "little")]
45pub const OPPOSING_ENDIAN: Endian = Endian::Big;
46/// The runtime opposing endian.
47#[cfg(target_endian = "big")]
48pub const OPPOSING_ENDIAN: Endian = Endian::Little;