pub trait PackedStruct: Sized {
const PACKED_SIZE: usize;
// Required methods
fn from_packed_bytes(bytes: &[u8]) -> Option<Self>;
fn to_packed_bytes(&self) -> Vec<u8> ⓘ;
// Provided methods
fn from_packed_slice(bytes: &[u8]) -> Option<Vec<Self>> { ... }
fn to_packed_slice(structs: &[Self]) -> Vec<u8> ⓘ { ... }
}Expand description
A trait for types that can be read from and written to packed byte representations.
This trait provides methods for handling structures that contain I24 values
mixed with native types, working around the nested packing limitation.
Required Associated Constants§
Sourceconst PACKED_SIZE: usize
const PACKED_SIZE: usize
The size in bytes of the packed representation.
Required Methods§
Sourcefn from_packed_bytes(bytes: &[u8]) -> Option<Self>
fn from_packed_bytes(bytes: &[u8]) -> Option<Self>
Provided Methods§
Sourcefn from_packed_slice(bytes: &[u8]) -> Option<Vec<Self>>
fn from_packed_slice(bytes: &[u8]) -> Option<Vec<Self>>
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.