pub trait SimpleEndian: Sized + Clone {
// Provided methods
fn to_big_endian(self) -> Self { ... }
fn to_little_endian(self) -> Self { ... }
fn from_big_endian(self) -> Self { ... }
fn from_little_endian(self) -> Self { ... }
fn endian(&self) -> Endian { ... }
}Expand description
A trait for types that do not change based on endianness.
Types implementing SimpleEndian have the same representation regardless of whether they are
stored in big-endian or little-endian byte order. This includes single-byte types, the unit type,
and other endianness-agnostic types.
All conversion methods are no-ops for these types, providing default implementations that simply return the value unchanged.
Provided Methods§
Sourcefn to_big_endian(self) -> Self
fn to_big_endian(self) -> Self
No-op conversion to big-endian representation (returns self unchanged).
Sourcefn to_little_endian(self) -> Self
fn to_little_endian(self) -> Self
No-op conversion to little-endian representation (returns self unchanged).
Sourcefn from_big_endian(self) -> Self
fn from_big_endian(self) -> Self
No-op conversion from big-endian representation (returns self unchanged).
Sourcefn from_little_endian(self) -> Self
fn from_little_endian(self) -> Self
No-op conversion from little-endian representation (returns self unchanged).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
impl SimpleEndian for &str
simple_string_impls only.Implement SimpleEndian for string slices &str.
impl SimpleEndian for bool
simple_bool only.Implement SimpleEndian for bool.
impl SimpleEndian for char
simple_char_impls only.Implement SimpleEndian for char (a Unicode scalar value; endianness-independent as a Rust value).
impl SimpleEndian for i8
simple_byte_impls only.Implement SimpleEndian for i8 (single byte, endianness-independent).
impl SimpleEndian for u8
simple_byte_impls only.Implement SimpleEndian for u8 (single byte, endianness-independent).
impl SimpleEndian for ()
Implement SimpleEndian for the unit type ().
impl SimpleEndian for String
simple_string_impls only.Implement SimpleEndian for owned strings String.