[][src]Struct read_from::NativeEndian

#[repr(transparent)]pub struct NativeEndian<T>(pub T);

A type that can be used to deserialize integers in native-endian format.

Example

use read_from::{WriteTo, ReadFrom, NativeEndian};
use std::io::Cursor;

let mut buf = vec![];
NativeEndian(0xaabbccdd_u32).write_to(&mut buf).unwrap();

if cfg!(target_endian="little") {
   assert_eq!(buf, [0xdd, 0xcc, 0xbb, 0xaa]);
} else {
   assert_eq!(buf, [0xaa, 0xbb, 0xcc, 0xdd]);
}

let cursor = Cursor::new(&buf);
assert_eq!(0xaabbccdd_u32, NativeEndian::read_from(cursor).unwrap().0);

Trait Implementations

impl<T: Clone> Clone for NativeEndian<T>[src]

impl<T: Copy> Copy for NativeEndian<T>[src]

impl<T: Debug> Debug for NativeEndian<T>[src]

impl<T: Default> Default for NativeEndian<T>[src]

impl<T: Eq> Eq for NativeEndian<T>[src]

impl<T: Hash> Hash for NativeEndian<T>[src]

impl<T: Ord> Ord for NativeEndian<T>[src]

impl<T: PartialEq> PartialEq<NativeEndian<T>> for NativeEndian<T>[src]

impl<T: PartialOrd> PartialOrd<NativeEndian<T>> for NativeEndian<T>[src]

impl ReadFrom for NativeEndian<u8>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<u16>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<i128>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<isize>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<f32>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<f64>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<u32>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<u64>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<u128>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<usize>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<i8>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<i16>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<i32>[src]

type Error = Error

What error can happen when trying to read?

impl ReadFrom for NativeEndian<i64>[src]

type Error = Error

What error can happen when trying to read?

impl<T> StructuralEq for NativeEndian<T>[src]

impl<T> StructuralPartialEq for NativeEndian<T>[src]

impl WriteTo for NativeEndian<u8>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<u16>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<i128>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<isize>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<f32>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<f64>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<u32>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<u64>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<u128>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<usize>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<i8>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<i16>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<i32>[src]

type Error = Error

What error can happen when trying to write?

impl WriteTo for NativeEndian<i64>[src]

type Error = Error

What error can happen when trying to write?

Auto Trait Implementations

impl<T> RefUnwindSafe for NativeEndian<T> where
    T: RefUnwindSafe

impl<T> Send for NativeEndian<T> where
    T: Send

impl<T> Sync for NativeEndian<T> where
    T: Sync

impl<T> Unpin for NativeEndian<T> where
    T: Unpin

impl<T> UnwindSafe for NativeEndian<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.