pub trait Endian:
Debug
+ Default
+ Clone
+ Copy
+ PartialEq
+ Eq
+ 'static {
Show 16 methods
// Required methods
fn from_big_endian(big_endian: bool) -> Option<Self>;
fn is_big_endian(self) -> bool;
// Provided methods
fn from_little_endian(little_endian: bool) -> Option<Self> { ... }
fn is_little_endian(self) -> bool { ... }
fn read_u16(self, n: [u8; 2]) -> u16 { ... }
fn read_u32(self, n: [u8; 4]) -> u32 { ... }
fn read_u64(self, n: [u8; 8]) -> u64 { ... }
fn read_i16(self, n: [u8; 2]) -> i16 { ... }
fn read_i32(self, n: [u8; 4]) -> i32 { ... }
fn read_i64(self, n: [u8; 8]) -> i64 { ... }
fn write_u16(self, n: u16) -> [u8; 2] { ... }
fn write_u32(self, n: u32) -> [u8; 4] { ... }
fn write_u64(self, n: u64) -> [u8; 8] { ... }
fn write_i16(self, n: i16) -> [u8; 2] { ... }
fn write_i32(self, n: i32) -> [u8; 4] { ... }
fn write_i64(self, n: i64) -> [u8; 8] { ... }
}Expand description
A trait for using an endianness specification.
Provides methods for converting between the specified endianness and the native endianness of the target machine.
This trait does not require that the endianness is known at compile time.
Required Methods§
Sourcefn from_big_endian(big_endian: bool) -> Option<Self>
fn from_big_endian(big_endian: bool) -> Option<Self>
Construct a specification for the endianness of some values.
Returns None if the type does not support specifying the given endianness.
Sourcefn is_big_endian(self) -> bool
fn is_big_endian(self) -> bool
Return true for big endian byte order.
Provided Methods§
Sourcefn from_little_endian(little_endian: bool) -> Option<Self>
fn from_little_endian(little_endian: bool) -> Option<Self>
Construct a specification for the endianness of some values.
Returns None if the type does not support specifying the given endianness.
Sourcefn is_little_endian(self) -> bool
fn is_little_endian(self) -> bool
Return true for little endian byte order.
Sourcefn read_u16(self, n: [u8; 2]) -> u16
fn read_u16(self, n: [u8; 2]) -> u16
Converts an unaligned unsigned 16 bit integer to native endian.
Sourcefn read_u32(self, n: [u8; 4]) -> u32
fn read_u32(self, n: [u8; 4]) -> u32
Converts an unaligned unsigned 32 bit integer to native endian.
Sourcefn read_u64(self, n: [u8; 8]) -> u64
fn read_u64(self, n: [u8; 8]) -> u64
Converts an unaligned unsigned 64 bit integer to native endian.
Sourcefn read_i16(self, n: [u8; 2]) -> i16
fn read_i16(self, n: [u8; 2]) -> i16
Converts an unaligned signed 16 bit integer to native endian.
Sourcefn read_i32(self, n: [u8; 4]) -> i32
fn read_i32(self, n: [u8; 4]) -> i32
Converts an unaligned signed 32 bit integer to native endian.
Sourcefn read_i64(self, n: [u8; 8]) -> i64
fn read_i64(self, n: [u8; 8]) -> i64
Converts an unaligned signed 64 bit integer to native endian.
Sourcefn write_u16(self, n: u16) -> [u8; 2]
fn write_u16(self, n: u16) -> [u8; 2]
Converts an unaligned unsigned 16 bit integer from native endian.
Sourcefn write_u32(self, n: u32) -> [u8; 4]
fn write_u32(self, n: u32) -> [u8; 4]
Converts an unaligned unsigned 32 bit integer from native endian.
Sourcefn write_u64(self, n: u64) -> [u8; 8]
fn write_u64(self, n: u64) -> [u8; 8]
Converts an unaligned unsigned 64 bit integer from native endian.
Sourcefn write_i16(self, n: i16) -> [u8; 2]
fn write_i16(self, n: i16) -> [u8; 2]
Converts an unaligned signed 16 bit integer from native endian.
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.