pub trait Byteable: Copy {
type ByteArray: ByteableByteArray;
const BINARY_SIZE: usize = <Self::ByteArray>::BINARY_SIZE;
// Required methods
fn as_bytearray(self) -> Self::ByteArray;
fn from_bytearray(ba: Self::ByteArray) -> Self;
}Expand description
Trait for types that can be converted to and from a byte array.
This trait is central to the byteable crate, enabling structured data
to be easily serialized into and deserialized from byte arrays.
Provided Associated Constants§
const BINARY_SIZE: usize = <Self::ByteArray>::BINARY_SIZE
Required Associated Types§
Sourcetype ByteArray: ByteableByteArray
type ByteArray: ByteableByteArray
The associated byte array type that can represent Self.
Required Methods§
Sourcefn as_bytearray(self) -> Self::ByteArray
fn as_bytearray(self) -> Self::ByteArray
Converts self into its ByteableByteArray representation.
Sourcefn from_bytearray(ba: Self::ByteArray) -> Self
fn from_bytearray(ba: Self::ByteArray) -> Self
Creates an instance of Self from a ByteableByteArray.
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.