Trait endian_trait::Endian [] [src]

pub trait Endian {
    fn to_be(self) -> Self;
fn to_le(self) -> Self;
fn from_be(self) -> Self;
fn from_le(self) -> Self; }

Convert a type from one endian order to another.

The standard implementation of this trait is simply to call the methods on the component members of a data type which are themselves Endian, until the call stack bottoms out at one of Rust's primitives.

Required Methods

Converts from host endian to big-endian order.

On big-endian platforms, this is a no-op and should be compiled out.

Converts from host endian to little-endian order.

On little-endian platforms, this is a no-op and should be compiled out.

Converts from big-endian order to host endian.

On big-endian platforms, this is a no-op and should be compiled out.

Converts from little-endian order to host endian.

On little-endian platforms, this is a no-op and should be compiled out.

Implementations on Foreign Types

impl<'a, T: Endian> Endian for &'a mut [T]
[src]

Traverse a slice, performing the Endian method on each item in place.

[src]

[src]

[src]

[src]

impl Endian for bool
[src]

Implement on bool.

bool is always one byte, and single bytes don`t have endian order.

[src]

[src]

[src]

[src]

impl Endian for char
[src]

Implement on char.

char is four bytes wide. Delegate to u32's implementation and transmute. This is safe ONLY IF THE CONVERSION MAKES LOGICAL SENSE char is Unicode codepoints, NOT integers, so not all values of u32 are valid values of char. The to_ functions will emit potentially invalid char values, and this is to be expected. The from_ functions, however, will panic if they are about to emit an invalid char byte value.

[src]

Attempts to create a local char from a big-endian value.

This function WILL panic if the local value exceeds the maximum Unicode Scalar Value permissible.

[src]

Attempts to create a local char from a little-endian value.

This function WILL panic if the local value exceeds the maximum Unicode Scalar Value permissible.

[src]

Converts a local char to big-endian.

This may result in a byte value that is not a valid Unicode Scalar Value and the result of this transform should be passed into a from_be() before using it in anything that requires char semantics.

[src]

Converts a local char to little-endian.

This may result in a byte value that is not a valid Unicode Scalar Value and the result of this transform should be passed into a from_le() before using it in anything that requires char semantics.

impl Endian for i8
[src]

[src]

[src]

[src]

[src]

impl Endian for u8
[src]

[src]

[src]

[src]

[src]

impl Endian for i16
[src]

[src]

[src]

[src]

[src]

impl Endian for u16
[src]

[src]

[src]

[src]

[src]

impl Endian for i32
[src]

[src]

[src]

[src]

[src]

impl Endian for u32
[src]

[src]

[src]

[src]

[src]

impl Endian for i64
[src]

[src]

[src]

[src]

[src]

impl Endian for u64
[src]

[src]

[src]

[src]

[src]

impl Endian for f32
[src]

[src]

[src]

[src]

[src]

impl Endian for f64
[src]

[src]

[src]

[src]

[src]

Implementors