Trait object::endian::Endian

source ·
pub trait Endian: Debug + Default + Clone + Copy + PartialEq + Eq + 'static {
Show 28 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: u16) -> u16 { ... } fn read_u32(self, n: u32) -> u32 { ... } fn read_u64(self, n: u64) -> u64 { ... } fn read_i16(self, n: i16) -> i16 { ... } fn read_i32(self, n: i32) -> i32 { ... } fn read_i64(self, n: i64) -> i64 { ... } fn read_u16_bytes(self, n: [u8; 2]) -> u16 { ... } fn read_u32_bytes(self, n: [u8; 4]) -> u32 { ... } fn read_u64_bytes(self, n: [u8; 8]) -> u64 { ... } fn read_i16_bytes(self, n: [u8; 2]) -> i16 { ... } fn read_i32_bytes(self, n: [u8; 4]) -> i32 { ... } fn read_i64_bytes(self, n: [u8; 8]) -> i64 { ... } fn write_u16(self, n: u16) -> u16 { ... } fn write_u32(self, n: u32) -> u32 { ... } fn write_u64(self, n: u64) -> u64 { ... } fn write_i16(self, n: i16) -> i16 { ... } fn write_i32(self, n: i32) -> i32 { ... } fn write_i64(self, n: i64) -> i64 { ... } fn write_u16_bytes(self, n: u16) -> [u8; 2] { ... } fn write_u32_bytes(self, n: u32) -> [u8; 4] { ... } fn write_u64_bytes(self, n: u64) -> [u8; 8] { ... } fn write_i16_bytes(self, n: i16) -> [u8; 2] { ... } fn write_i32_bytes(self, n: i32) -> [u8; 4] { ... } fn write_i64_bytes(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§

source

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.

source

fn is_big_endian(self) -> bool

Return true for big endian byte order.

Provided Methods§

source

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.

source

fn is_little_endian(self) -> bool

Return true for little endian byte order.

source

fn read_u16(self, n: u16) -> u16

Converts an unsigned 16 bit integer to native endian.

source

fn read_u32(self, n: u32) -> u32

Converts an unsigned 32 bit integer to native endian.

source

fn read_u64(self, n: u64) -> u64

Converts an unsigned 64 bit integer to native endian.

source

fn read_i16(self, n: i16) -> i16

Converts a signed 16 bit integer to native endian.

source

fn read_i32(self, n: i32) -> i32

Converts a signed 32 bit integer to native endian.

source

fn read_i64(self, n: i64) -> i64

Converts a signed 64 bit integer to native endian.

source

fn read_u16_bytes(self, n: [u8; 2]) -> u16

Converts an unaligned unsigned 16 bit integer to native endian.

source

fn read_u32_bytes(self, n: [u8; 4]) -> u32

Converts an unaligned unsigned 32 bit integer to native endian.

source

fn read_u64_bytes(self, n: [u8; 8]) -> u64

Converts an unaligned unsigned 64 bit integer to native endian.

source

fn read_i16_bytes(self, n: [u8; 2]) -> i16

Converts an unaligned signed 16 bit integer to native endian.

source

fn read_i32_bytes(self, n: [u8; 4]) -> i32

Converts an unaligned signed 32 bit integer to native endian.

source

fn read_i64_bytes(self, n: [u8; 8]) -> i64

Converts an unaligned signed 64 bit integer to native endian.

source

fn write_u16(self, n: u16) -> u16

Converts an unsigned 16 bit integer from native endian.

source

fn write_u32(self, n: u32) -> u32

Converts an unsigned 32 bit integer from native endian.

source

fn write_u64(self, n: u64) -> u64

Converts an unsigned 64 bit integer from native endian.

source

fn write_i16(self, n: i16) -> i16

Converts a signed 16 bit integer from native endian.

source

fn write_i32(self, n: i32) -> i32

Converts a signed 32 bit integer from native endian.

source

fn write_i64(self, n: i64) -> i64

Converts a signed 64 bit integer from native endian.

source

fn write_u16_bytes(self, n: u16) -> [u8; 2]

Converts an unaligned unsigned 16 bit integer from native endian.

source

fn write_u32_bytes(self, n: u32) -> [u8; 4]

Converts an unaligned unsigned 32 bit integer from native endian.

source

fn write_u64_bytes(self, n: u64) -> [u8; 8]

Converts an unaligned unsigned 64 bit integer from native endian.

source

fn write_i16_bytes(self, n: i16) -> [u8; 2]

Converts an unaligned signed 16 bit integer from native endian.

source

fn write_i32_bytes(self, n: i32) -> [u8; 4]

Converts an unaligned signed 32 bit integer from native endian.

source

fn write_i64_bytes(self, n: i64) -> [u8; 8]

Converts an unaligned signed 64 bit integer from native endian.

Object Safety§

This trait is not object safe.

Implementors§