Expand description
Optional proc macro DX layer for Hopper.
Provides both the canonical #[hopper::state], #[hopper::context],
#[hopper::program] surface and the legacy #[hopper_state],
#[hopper_context], #[hopper_program] aliases. All entry points generate
zero-cost code targeting Hopper’s runtime primitives.
Not required. Every feature these macros provide is achievable through
Hopper’s declarative macro_rules! macros or hand-written code. These
exist purely for developer velocity. The generated code compiles to the
exact same pointer arithmetic as raw Pinocchio.
§Design Philosophy
- Macros generate code, not behavior. No hidden runtime logic.
- Everything inlines. No function calls that wouldn’t exist in hand-written code.
- No heap. Generated code is
no_std,no_alloc. - Optional. Core Hopper never depends on this crate.
Macros§
- declare_
program - Generate a typed CPI surface from an on-disk Hopper manifest.
Attribute Macros§
- account
- Anchor / Quasar naming alias for [
state]. - accounts
- Anchor-style plural alias for [
context]. - args
- Short alias:
#[hopper::args]. - constant
- Short alias:
#[hopper::constant]. - context
- crank
- Short alias:
#[hopper::crank]. - dynamic
- Short alias:
#[hopper::dynamic(field = "…")]. - dynamic_
account - Short alias:
#[hopper::dynamic_account]. - error
- Short alias:
#[hopper::error]. - event
- Short alias:
#[hopper::event]. - hopper_
args - Derive a zero-copy borrowing parser for an instruction argument struct.
- hopper_
constant - Mark a
pub constso it is surfaced in the Anchor IDL"constants"array. - hopper_
context - Generate typed context accessors with segment-level borrow tracking.
- hopper_
crank - Mark an instruction handler as an autonomous crank.
- hopper_
dynamic - Declare which field of a
#[repr(C)]struct is the dynamic-tail region. - hopper_
dynamic_ account - Quasar-style bounded dynamic fields lowered into Hopper’s fixed-body + compact-tail account layout.
- hopper_
error - Derive a Hopper error-code enum. Emits
code(),variant_name(),From<T> for u32, and two const tables (CODE_TABLE,INVARIANT_TABLE) that the schema crate surfaces in the manifest. - hopper_
event - Derive a Hopper event: emits a stable 1-byte tag, optional segment source,
a
NAMEstring, aFIELD_COUNTconst, and anas_bytes(&self)view for the framework’s log-emission pathway. - hopper_
migrate - Declare a schema-epoch migration edge.
- hopper_
pod - Derive the Hopper zero-copy marker contract for a user-defined struct.
- hopper_
program - Generate a dispatch table for a Hopper program module.
- hopper_
state - Generate a
SegmentMapimplementation for a zero-copy layout struct. - migrate
- Short alias:
#[hopper::migrate]. Functionally identical to#[hopper_migrate]. - pod
- Short alias:
#[hopper::pod]. Functionally identical to#[hopper_pod]. - program
- state
Derive Macros§
- Accounts
#[derive(Accounts)]- Anchor-spelled drop-in for#[hopper::context].- Hopper
Init Space - Derive
const INIT_SPACE: usize = size_of::<Self>()on a struct.