#[non_exhaustive]#[repr(u8)]pub enum ByteOrder {
Little = 0,
Big = 1,
}Expand description
Byte order to use when encoding numbers.
By default, this is the ByteOrder::NATIVE byte order of the target
platform.
§Examples
use musli::options::{self, ByteOrder};
const OPTIONS_LITTLE: musli::options::Options = options::new()
.byte_order(ByteOrder::Little)
.build();
const OPTIONS_BIG: musli::options::Options = options::new()
.byte_order(ByteOrder::Big)
.build();
const OPTIONS_NATIVE: musli::options::Options = options::new()
.byte_order(ByteOrder::NATIVE)
.build();Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Implementations§
Source§impl ByteOrder
impl ByteOrder
Sourcepub const NETWORK: Self = Self::Big
pub const NETWORK: Self = Self::Big
The network byte order.
This is the same as Big.
§Examples
use musli::options::{self, ByteOrder};
use musli::packed::Encoding;
// Configure network byte order (big endian) for cross-platform compatibility
const OPTIONS: musli::options::Options = options::new()
.byte_order(ByteOrder::NETWORK)
.build();
const CONFIG: Encoding<OPTIONS> = Encoding::new().with_options();
let data = CONFIG.to_vec(&0x1234u16)?;
let decoded: u16 = CONFIG.from_slice(&data)?;
assert_eq!(decoded, 0x1234);Trait Implementations§
impl Eq for ByteOrder
impl StructuralPartialEq for ByteOrder
Auto Trait Implementations§
impl Freeze for ByteOrder
impl RefUnwindSafe for ByteOrder
impl Send for ByteOrder
impl Sync for ByteOrder
impl Unpin for ByteOrder
impl UnsafeUnpin for ByteOrder
impl UnwindSafe for ByteOrder
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