pub trait Byteable: Copy {
type ByteArray: ByteableByteArray;
// Required methods
fn as_bytearray(self) -> Self::ByteArray;
fn from_bytearray(ba: Self::ByteArray) -> Self;
fn binary_size() -> usize;
}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.
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.
Sourcefn binary_size() -> usize
fn binary_size() -> usize
Returns the size in bytes of the binary representation of this type.
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.