Skip to main content

hopper_state

Attribute Macro hopper_state 

Source
#[hopper_state]
Expand description

Generate a SegmentMap implementation for a zero-copy layout struct.

Computes field offsets at compile time and emits a const segment table. The generated code is zero-cost. Segment lookups resolve to const loads.

§Example

#[hopper_state]
#[repr(C)]
pub struct Vault {
    pub authority: [u8; 32],  // TypedAddress<Authority>
    pub balance: [u8; 8],     // WireU64
    pub bump: u8,
}

// Generated:
// impl SegmentMap for Vault { ... }
// const VAULT_SEGMENTS: ... (for direct access)