zerodds_wire/endianness.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 ZeroDDS Contributors
3//! Byte order.
4
5/// Which byte order a stream is in.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub enum Endianness {
8 /// Most significant byte first. The order a KeyHash holder is always
9 /// in, whatever the sample is. DDSI-RTPS 2.5 ยง9.6.3.8.
10 Big,
11 /// Least significant byte first.
12 Little,
13}
14
15impl Endianness {
16 /// Both orders.
17 pub const ALL: [Self; 2] = [Self::Big, Self::Little];
18
19 /// Whether this is little-endian.
20 #[must_use]
21 pub const fn is_little(self) -> bool {
22 matches!(self, Self::Little)
23 }
24}