Trait lebe::Endian

source ·
pub trait Endian {
    // Required method
    fn swap_bytes(&mut self);

    // Provided methods
    fn convert_current_to_little_endian(&mut self) { ... }
    fn convert_current_to_big_endian(&mut self) { ... }
    fn convert_little_endian_to_current(&mut self) { ... }
    fn convert_big_endian_to_current(&mut self) { ... }
    fn from_current_into_little_endian(self) -> Self
       where Self: Sized { ... }
    fn from_current_into_big_endian(self) -> Self
       where Self: Sized { ... }
    fn from_little_endian_into_current(self) -> Self
       where Self: Sized { ... }
    fn from_big_endian_into_current(self) -> Self
       where Self: Sized { ... }
}
Expand description

Represents values that can swap their bytes to reverse their endianness.

Supports converting values in-place using [swap_bytes] or [convert_current_to_little_endian]: Supports converting while transferring ownership using [from_little_endian_into_current] or [from_current_into_little_endian].

For the types u8, i8, &[u8] and &[i8], this trait will never transform any data, as they are just implemented for completeness.

Required Methods§

source

fn swap_bytes(&mut self)

Swaps all bytes in this value, inverting its endianness.

Provided Methods§

source

fn convert_current_to_little_endian(&mut self)

On a little endian machine, this does nothing. On a big endian machine, the bytes of this value are reversed.

source

fn convert_current_to_big_endian(&mut self)

On a big endian machine, this does nothing. On a little endian machine, the bytes of this value are reversed.

source

fn convert_little_endian_to_current(&mut self)

On a little endian machine, this does nothing. On a big endian machine, the bytes of this value are reversed.

source

fn convert_big_endian_to_current(&mut self)

On a big endian machine, this does nothing. On a little endian machine, the bytes of this value are reversed.

source

fn from_current_into_little_endian(self) -> Selfwhere Self: Sized,

On a little endian machine, this does nothing. On a big endian machine, the bytes of this value are reversed.

source

fn from_current_into_big_endian(self) -> Selfwhere Self: Sized,

On a big endian machine, this does nothing. On a little endian machine, the bytes of this value are reversed.

source

fn from_little_endian_into_current(self) -> Selfwhere Self: Sized,

On a little endian machine, this does nothing. On a big endian machine, the bytes of this value are reversed.

source

fn from_big_endian_into_current(self) -> Selfwhere Self: Sized,

On a big endian machine, this does nothing. On a little endian machine, the bytes of this value are reversed.

Implementations on Foreign Types§

source§

impl Endian for [i8]

source§

fn swap_bytes(&mut self)

source§

impl Endian for [i16]

source§

fn swap_bytes(&mut self)

source§

impl Endian for i128

source§

fn swap_bytes(&mut self)

source§

impl Endian for i64

source§

fn swap_bytes(&mut self)

source§

impl Endian for [f64]

source§

fn swap_bytes(&mut self)

source§

impl Endian for [u64]

source§

fn swap_bytes(&mut self)

source§

impl Endian for u16

source§

fn swap_bytes(&mut self)

source§

impl Endian for [i64]

source§

fn swap_bytes(&mut self)

source§

impl Endian for f32

source§

fn swap_bytes(&mut self)

source§

impl Endian for [i128]

source§

fn swap_bytes(&mut self)

source§

impl Endian for u128

source§

fn swap_bytes(&mut self)

source§

impl Endian for [u32]

source§

fn swap_bytes(&mut self)

source§

impl Endian for [u8]

source§

fn swap_bytes(&mut self)

source§

impl Endian for u8

source§

fn swap_bytes(&mut self)

source§

impl Endian for i8

source§

fn swap_bytes(&mut self)

source§

impl Endian for [i32]

source§

fn swap_bytes(&mut self)

source§

impl Endian for i16

source§

fn swap_bytes(&mut self)

source§

impl Endian for u64

source§

fn swap_bytes(&mut self)

source§

impl Endian for [u16]

source§

fn swap_bytes(&mut self)

source§

impl Endian for u32

source§

fn swap_bytes(&mut self)

source§

impl Endian for [u128]

source§

fn swap_bytes(&mut self)

source§

impl Endian for f64

source§

fn swap_bytes(&mut self)

source§

impl Endian for [f32]

source§

fn swap_bytes(&mut self)

source§

impl Endian for i32

source§

fn swap_bytes(&mut self)

Implementors§