pub trait CompactLayout:
Sized
+ Copy
+ Pod {
const DISC: u8;
const BODY_SIZE: usize = _;
const COMPACT_LEN: usize = _;
// Provided method
fn validate_compact(data: &[u8]) -> ProgramResult { ... }
}Expand description
A zero-copy account layout stored in compact [disc:u8][body] form.
§Safety
The blanket access methods overlay Self directly on account bytes
starting at COMPACT_BODY_OFFSET. Implementing this trait asserts
the same contract as crate::Pod for the body: alignment 1, no
padding, every bit pattern valid, no internal pointers. The Pod
supertrait carries that obligation; CompactLayout only adds the
discriminator and the compact wire-length math.
Required Associated Constants§
Provided Associated Constants§
Sourceconst COMPACT_LEN: usize = _
const COMPACT_LEN: usize = _
Total compact wire length: 1 discriminator byte + body.
Provided Methods§
Sourcefn validate_compact(data: &[u8]) -> ProgramResult
fn validate_compact(data: &[u8]) -> ProgramResult
Validate that data is a compact account of this type.
Checks the buffer has exactly the fixed compact wire length and the discriminator at byte 0 matches. Deliberately does not read a layout_id or epoch.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".