pub struct BigEndian<T: EndianConvert>(/* private fields */);Expand description
A transparent wrapper that stores an EndianConvert value in big-endian byte order.
BigEndian<T> is #[repr(transparent)] and implements PlainOldData, so it can be
embedded directly in #[repr(C, packed)] raw structs used for zero-copy serialization.
Use new to construct from a native-endian value, and
get to retrieve the native-endian value.
§Examples
use byteable::{BigEndian, ToByteArray};
let be = BigEndian::new(0x1234u16);
assert_eq!(be.get(), 0x1234u16);
// The internal bytes are stored in big-endian order:
assert_eq!(be.to_byte_array(), [0x12, 0x34]);Implementations§
Trait Implementations§
impl<T: Copy + EndianConvert> Copy for BigEndian<T>
impl<T: Eq + EndianConvert> Eq for BigEndian<T>
Source§impl<T: EndianConvert> From<T> for BigEndian<T>
impl<T: EndianConvert> From<T> for BigEndian<T>
Source§impl FromByteArray for BigEndian<u16>
impl FromByteArray for BigEndian<u16>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl FromByteArray for BigEndian<u32>
impl FromByteArray for BigEndian<u32>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl FromByteArray for BigEndian<u64>
impl FromByteArray for BigEndian<u64>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl FromByteArray for BigEndian<u128>
impl FromByteArray for BigEndian<u128>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl FromByteArray for BigEndian<i16>
impl FromByteArray for BigEndian<i16>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl FromByteArray for BigEndian<i32>
impl FromByteArray for BigEndian<i32>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl FromByteArray for BigEndian<i64>
impl FromByteArray for BigEndian<i64>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl FromByteArray for BigEndian<i128>
impl FromByteArray for BigEndian<i128>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl FromByteArray for BigEndian<f32>
impl FromByteArray for BigEndian<f32>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl FromByteArray for BigEndian<f64>
impl FromByteArray for BigEndian<f64>
Source§fn from_byte_array(byte_array: Self::ByteArray) -> Self
fn from_byte_array(byte_array: Self::ByteArray) -> Self
Deserialize a value from a fixed-size byte array. Infallible.
Source§impl<T: EndianConvert> FromRawRepr for BigEndian<T>
impl<T: EndianConvert> FromRawRepr for BigEndian<T>
Source§impl<T: Ord + EndianConvert> Ord for BigEndian<T>
impl<T: Ord + EndianConvert> Ord for BigEndian<T>
1.21.0 (const: unstable) · 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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<T: PartialOrd + EndianConvert> PartialOrd for BigEndian<T>
impl<T: PartialOrd + EndianConvert> PartialOrd for BigEndian<T>
Source§impl<T: EndianConvert + PlainOldData> PlainOldData for BigEndian<T>
impl<T: EndianConvert + PlainOldData> PlainOldData for BigEndian<T>
Source§impl<T: EndianConvert> RawRepr for BigEndian<T>
impl<T: EndianConvert> RawRepr for BigEndian<T>
Source§impl ToByteArray for BigEndian<u16>
impl ToByteArray for BigEndian<u16>
Source§impl ToByteArray for BigEndian<u32>
impl ToByteArray for BigEndian<u32>
Source§impl ToByteArray for BigEndian<u64>
impl ToByteArray for BigEndian<u64>
Source§impl ToByteArray for BigEndian<u128>
impl ToByteArray for BigEndian<u128>
Source§impl ToByteArray for BigEndian<i16>
impl ToByteArray for BigEndian<i16>
Source§impl ToByteArray for BigEndian<i32>
impl ToByteArray for BigEndian<i32>
Source§impl ToByteArray for BigEndian<i64>
impl ToByteArray for BigEndian<i64>
Source§impl ToByteArray for BigEndian<i128>
impl ToByteArray for BigEndian<i128>
Source§impl ToByteArray for BigEndian<f32>
impl ToByteArray for BigEndian<f32>
Source§impl ToByteArray for BigEndian<f64>
impl ToByteArray for BigEndian<f64>
Source§impl<T: EndianConvert> TryFromRawRepr for BigEndian<T>
impl<T: EndianConvert> TryFromRawRepr for BigEndian<T>
Source§fn try_from_raw(raw: Self::Raw) -> Result<Self, DecodeError>
fn try_from_raw(raw: Self::Raw) -> Result<Self, DecodeError>
Attempt to convert a raw representation into
Self. Read moreSource§impl WireFingerprint for BigEndian<u16>
impl WireFingerprint for BigEndian<u16>
const WIRE_FINGERPRINT: u64
Source§impl WireFingerprint for BigEndian<u32>
impl WireFingerprint for BigEndian<u32>
const WIRE_FINGERPRINT: u64
Source§impl WireFingerprint for BigEndian<u64>
impl WireFingerprint for BigEndian<u64>
const WIRE_FINGERPRINT: u64
Source§impl WireFingerprint for BigEndian<u128>
impl WireFingerprint for BigEndian<u128>
const WIRE_FINGERPRINT: u64
Source§impl WireFingerprint for BigEndian<i16>
impl WireFingerprint for BigEndian<i16>
const WIRE_FINGERPRINT: u64
Source§impl WireFingerprint for BigEndian<i32>
impl WireFingerprint for BigEndian<i32>
const WIRE_FINGERPRINT: u64
Source§impl WireFingerprint for BigEndian<i64>
impl WireFingerprint for BigEndian<i64>
const WIRE_FINGERPRINT: u64
Source§impl WireFingerprint for BigEndian<i128>
impl WireFingerprint for BigEndian<i128>
const WIRE_FINGERPRINT: u64
Source§impl WireFingerprint for BigEndian<f32>
impl WireFingerprint for BigEndian<f32>
const WIRE_FINGERPRINT: u64
Source§impl WireFingerprint for BigEndian<f64>
impl WireFingerprint for BigEndian<f64>
const WIRE_FINGERPRINT: u64
Auto Trait Implementations§
impl<T> Forget for BigEndian<T>
impl<T> Freeze for BigEndian<T>where
T: Freeze,
impl<T> Move for BigEndian<T>
impl<T> RefUnwindSafe for BigEndian<T>where
T: RefUnwindSafe,
impl<T> Send for BigEndian<T>where
T: Send,
impl<T> Sync for BigEndian<T>where
T: Sync,
impl<T> Unpin for BigEndian<T>where
T: Unpin,
impl<T> UnsafeUnpin for BigEndian<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for BigEndian<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FixedReadable for Twhere
T: TryFromRawRepr,
impl<T> FixedReadable for Twhere
T: TryFromRawRepr,
Source§fn read_fixed_from(
reader: &mut (impl Read + ?Sized),
) -> Result<T, ReadableError>
fn read_fixed_from( reader: &mut (impl Read + ?Sized), ) -> Result<T, ReadableError>
Source§impl<T> FixedWritable for Twhere
T: RawRepr,
impl<T> FixedWritable for Twhere
T: RawRepr,
Source§impl<T> Readable for Twhere
T: FixedReadable,
impl<T> Readable for Twhere
T: FixedReadable,
Source§impl<T> TryFromByteArray for Twhere
T: FromByteArray,
impl<T> TryFromByteArray for Twhere
T: FromByteArray,
Source§fn try_from_byte_array(
byte_array: <T as ToByteArray>::ByteArray,
) -> Result<T, DecodeError>
fn try_from_byte_array( byte_array: <T as ToByteArray>::ByteArray, ) -> Result<T, DecodeError>
Attempt to deserialize a value from a fixed-size byte array. Read more