pub trait NativeType:
Sealed
+ Pod
+ Send
+ Sync
+ Sized
+ RefUnwindSafe
+ Debug
+ Display
+ PartialEq
+ Default
+ Copy
+ TotalOrd
+ IsNull
+ MinMax
+ AlignedBytesCast<Self::AlignedBytes> {
type Bytes: AsRef<[u8]> + AsMut<[u8]> + Index<usize, Output = u8> + IndexMut<usize, Output = u8> + for<'a> TryFrom<&'a [u8]> + Debug + Default + IntoIterator<Item = u8>;
type AlignedBytes: AlignedBytes<Unaligned = Self::Bytes> + From<Self> + Into<Self>;
const PRIMITIVE: PrimitiveType;
// Required methods
fn to_le_bytes(&self) -> Self::Bytes;
fn to_be_bytes(&self) -> Self::Bytes;
fn from_le_bytes(bytes: Self::Bytes) -> Self;
fn from_be_bytes(bytes: Self::Bytes) -> Self;
}
Expand description
Sealed trait implemented by all physical types that can be allocated, serialized and deserialized by this crate. All O(N) allocations in this crate are done for this trait alone.
Required Associated Constants§
Sourceconst PRIMITIVE: PrimitiveType
const PRIMITIVE: PrimitiveType
The corresponding variant of PrimitiveType
.
Required Associated Types§
Sourcetype Bytes: AsRef<[u8]> + AsMut<[u8]> + Index<usize, Output = u8> + IndexMut<usize, Output = u8> + for<'a> TryFrom<&'a [u8]> + Debug + Default + IntoIterator<Item = u8>
type Bytes: AsRef<[u8]> + AsMut<[u8]> + Index<usize, Output = u8> + IndexMut<usize, Output = u8> + for<'a> TryFrom<&'a [u8]> + Debug + Default + IntoIterator<Item = u8>
Type denoting its representation as bytes.
This is [u8; N]
where N = size_of::<T>
.
Sourcetype AlignedBytes: AlignedBytes<Unaligned = Self::Bytes> + From<Self> + Into<Self>
type AlignedBytes: AlignedBytes<Unaligned = Self::Bytes> + From<Self> + Into<Self>
Type denoting its representation as aligned bytes.
This is [u8; N]
where N = size_of::<Self>
and has alignment align_of::<Self>
.
Required Methods§
Sourcefn to_le_bytes(&self) -> Self::Bytes
fn to_le_bytes(&self) -> Self::Bytes
To bytes in little endian
Sourcefn to_be_bytes(&self) -> Self::Bytes
fn to_be_bytes(&self) -> Self::Bytes
To bytes in big endian
Sourcefn from_le_bytes(bytes: Self::Bytes) -> Self
fn from_le_bytes(bytes: Self::Bytes) -> Self
From bytes in little endian
Sourcefn from_be_bytes(bytes: Self::Bytes) -> Self
fn from_be_bytes(bytes: Self::Bytes) -> Self
From bytes in big endian
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.