Skip to main content

PackedStruct

Trait PackedStruct 

Source
pub trait PackedStruct: Sized {
    const PACKED_SIZE: usize;

    // Required method
    fn from_packed_bytes(bytes: &[u8]) -> Option<Self>;
}
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§

Source

const PACKED_SIZE: usize

The size in bytes of the packed representation.

Required Methods§

Source

fn from_packed_bytes(bytes: &[u8]) -> Option<Self>

Reads a single instance from packed bytes.

§Arguments
  • bytes - A byte slice containing the packed representation. Must be at least PACKED_SIZE bytes long.
§Returns

The deserialized structure, or None if the input is too short.

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.

Implementors§