/rust/registry/src/index.crates.io-6f17d22bba15001f/scroll-0.10.2/src/endian.rs
Line | Count | Source (jump to first uncovered line) |
1 | | #[derive(PartialEq, Eq, Copy, Debug, Clone)] |
2 | | /// The endianness (byte order) of a stream of bytes |
3 | | pub enum Endian { |
4 | | Little, |
5 | | Big, |
6 | | } |
7 | | |
8 | | /// Little Endian byte order context |
9 | | pub const LE: Endian = Endian::Little; |
10 | | /// Big Endian byte order context |
11 | | pub const BE: Endian = Endian::Big; |
12 | | /// Network byte order context |
13 | | pub const NETWORK: Endian = Endian::Big; |
14 | | #[cfg(target_endian = "little")] |
15 | | /// The machine's native byte order |
16 | | pub const NATIVE: Endian = LE; |
17 | | #[cfg(target_endian = "big")] |
18 | | /// The machine's native byte order |
19 | | pub const NATIVE: Endian = BE; |
20 | | |
21 | | impl Default for Endian { |
22 | | #[inline] |
23 | 67.6M | fn default() -> Self { |
24 | 67.6M | NATIVE |
25 | 67.6M | } <scroll::endian::Endian as core::default::Default>::default Line | Count | Source | 23 | 1.70k | fn default() -> Self { | 24 | 1.70k | NATIVE | 25 | 1.70k | } |
<scroll::endian::Endian as core::default::Default>::default Line | Count | Source | 23 | 21.9k | fn default() -> Self { | 24 | 21.9k | NATIVE | 25 | 21.9k | } |
Unexecuted instantiation: <scroll::endian::Endian as core::default::Default>::default <scroll::endian::Endian as core::default::Default>::default Line | Count | Source | 23 | 2.75M | fn default() -> Self { | 24 | 2.75M | NATIVE | 25 | 2.75M | } |
<scroll::endian::Endian as core::default::Default>::default Line | Count | Source | 23 | 64.9M | fn default() -> Self { | 24 | 64.9M | NATIVE | 25 | 64.9M | } |
|
26 | | } |
27 | | |
28 | | impl From<bool> for Endian { |
29 | | #[inline] |
30 | 0 | fn from(little_endian: bool) -> Self { |
31 | 0 | if little_endian { LE } else { BE } |
32 | 0 | } |
33 | | } |
34 | | |
35 | | impl Endian { |
36 | | #[inline] |
37 | 0 | pub fn network() -> Endian { |
38 | 0 | NETWORK |
39 | 0 | } |
40 | | #[inline] |
41 | 181M | pub fn is_little(&self) -> bool { |
42 | 181M | match *self { |
43 | 181M | LE => true, |
44 | 0 | _ => false, |
45 | | } |
46 | 181M | } <scroll::endian::Endian>::is_little Line | Count | Source | 41 | 594k | pub fn is_little(&self) -> bool { | 42 | 594k | match *self { | 43 | 594k | LE => true, | 44 | 0 | _ => false, | 45 | | } | 46 | 594k | } |
Unexecuted instantiation: <scroll::endian::Endian>::is_little <scroll::endian::Endian>::is_little Line | Count | Source | 41 | 18.5M | pub fn is_little(&self) -> bool { | 42 | 18.5M | match *self { | 43 | 18.5M | LE => true, | 44 | 0 | _ => false, | 45 | | } | 46 | 18.5M | } |
<scroll::endian::Endian>::is_little Line | Count | Source | 41 | 162M | pub fn is_little(&self) -> bool { | 42 | 162M | match *self { | 43 | 162M | LE => true, | 44 | 0 | _ => false, | 45 | | } | 46 | 162M | } |
|
47 | | } |