#[repr(transparent)]pub struct NativeEndian<T>(pub T);
Expand description
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);
Tuple Fields§
§0: T
Trait Implementations§
Source§impl<T: Clone> Clone for NativeEndian<T>
impl<T: Clone> Clone for NativeEndian<T>
Source§fn clone(&self) -> NativeEndian<T>
fn clone(&self) -> NativeEndian<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for NativeEndian<T>
impl<T: Debug> Debug for NativeEndian<T>
Source§impl<T: Default> Default for NativeEndian<T>
impl<T: Default> Default for NativeEndian<T>
Source§fn default() -> NativeEndian<T>
fn default() -> NativeEndian<T>
Returns the “default value” for a type. Read more
Source§impl<T: Hash> Hash for NativeEndian<T>
impl<T: Hash> Hash for NativeEndian<T>
Source§impl<T: Ord> Ord for NativeEndian<T>
impl<T: Ord> Ord for NativeEndian<T>
Source§fn cmp(&self, other: &NativeEndian<T>) -> Ordering
fn cmp(&self, other: &NativeEndian<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq> PartialEq for NativeEndian<T>
impl<T: PartialEq> PartialEq for NativeEndian<T>
Source§impl<T: PartialOrd> PartialOrd for NativeEndian<T>
impl<T: PartialOrd> PartialOrd for NativeEndian<T>
Source§impl ReadFrom for NativeEndian<f32>
impl ReadFrom for NativeEndian<f32>
Source§impl ReadFrom for NativeEndian<f64>
impl ReadFrom for NativeEndian<f64>
Source§impl ReadFrom for NativeEndian<i128>
impl ReadFrom for NativeEndian<i128>
Source§impl ReadFrom for NativeEndian<i16>
impl ReadFrom for NativeEndian<i16>
Source§impl ReadFrom for NativeEndian<i32>
impl ReadFrom for NativeEndian<i32>
Source§impl ReadFrom for NativeEndian<i64>
impl ReadFrom for NativeEndian<i64>
Source§impl ReadFrom for NativeEndian<i8>
impl ReadFrom for NativeEndian<i8>
Source§impl ReadFrom for NativeEndian<isize>
impl ReadFrom for NativeEndian<isize>
Source§impl ReadFrom for NativeEndian<u128>
impl ReadFrom for NativeEndian<u128>
Source§impl ReadFrom for NativeEndian<u16>
impl ReadFrom for NativeEndian<u16>
Source§impl ReadFrom for NativeEndian<u32>
impl ReadFrom for NativeEndian<u32>
Source§impl ReadFrom for NativeEndian<u64>
impl ReadFrom for NativeEndian<u64>
Source§impl ReadFrom for NativeEndian<u8>
impl ReadFrom for NativeEndian<u8>
Source§impl ReadFrom for NativeEndian<usize>
impl ReadFrom for NativeEndian<usize>
Source§impl WriteTo for NativeEndian<f32>
impl WriteTo for NativeEndian<f32>
Source§impl WriteTo for NativeEndian<f64>
impl WriteTo for NativeEndian<f64>
Source§impl WriteTo for NativeEndian<i128>
impl WriteTo for NativeEndian<i128>
Source§impl WriteTo for NativeEndian<i16>
impl WriteTo for NativeEndian<i16>
Source§impl WriteTo for NativeEndian<i32>
impl WriteTo for NativeEndian<i32>
Source§impl WriteTo for NativeEndian<i64>
impl WriteTo for NativeEndian<i64>
Source§impl WriteTo for NativeEndian<i8>
impl WriteTo for NativeEndian<i8>
Source§impl WriteTo for NativeEndian<isize>
impl WriteTo for NativeEndian<isize>
Source§impl WriteTo for NativeEndian<u128>
impl WriteTo for NativeEndian<u128>
Source§impl WriteTo for NativeEndian<u16>
impl WriteTo for NativeEndian<u16>
Source§impl WriteTo for NativeEndian<u32>
impl WriteTo for NativeEndian<u32>
Source§impl WriteTo for NativeEndian<u64>
impl WriteTo for NativeEndian<u64>
Source§impl WriteTo for NativeEndian<u8>
impl WriteTo for NativeEndian<u8>
Source§impl WriteTo for NativeEndian<usize>
impl WriteTo for NativeEndian<usize>
impl<T: Copy> Copy for NativeEndian<T>
impl<T: Eq> Eq for NativeEndian<T>
impl<T> StructuralPartialEq for NativeEndian<T>
Auto Trait Implementations§
impl<T> Freeze for NativeEndian<T>where
T: Freeze,
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more