pub trait NativeType: Sealed + Pod + Send + Sync + Debug + Display + PartialEq<Self> + Default {
type Bytes: AsRef<[u8]> + Index<usize> + IndexMut<usize> + for<'a> TryFrom<&'a [u8]> + Debug
where
<Self::Bytes as Index<usize>>::Output == u8,
<Self::Bytes as Index<usize>>::Output == u8;
const PRIMITIVE: PrimitiveType;
fn to_le_bytes(&self) -> Self::Bytes;
fn to_ne_bytes(&self) -> Self::Bytes;
fn to_be_bytes(&self) -> Self::Bytes;
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.
Associated Types
Associated Constants
const PRIMITIVE: PrimitiveType
const PRIMITIVE: PrimitiveType
The corresponding variant of PrimitiveType
.
Required methods
fn to_le_bytes(&self) -> Self::Bytes
fn to_le_bytes(&self) -> Self::Bytes
To bytes in little endian
fn to_ne_bytes(&self) -> Self::Bytes
fn to_ne_bytes(&self) -> Self::Bytes
To bytes in native endian
fn to_be_bytes(&self) -> Self::Bytes
fn to_be_bytes(&self) -> Self::Bytes
To bytes in big endian
fn from_be_bytes(bytes: Self::Bytes) -> Self
fn from_be_bytes(bytes: Self::Bytes) -> Self
From bytes in big endian