Expand description
§Hopper Macros (Declarative)
Support infrastructure, not the main public entry. These
macro_rules! macros generate layout structure, field metadata, and
validation primitives at compile time. They are deliberately limited
to structure generation: no hidden runtime logic, no surprise
control flow, no validation engines.
Programs that want richer DX should enable the proc-macros feature
and reach for #[hopper::state], #[hopper::context], and
#[hopper::program] in hopper-macros-proc. Programs that prefer a
zero-tool-chain authoring path can use these declarative macros
directly, both paths lower to the same runtime.
§Topical index
| Section | Macros |
|---|---|
| Layout | hopper_layout! |
| Validation | hopper_check!, hopper_error!, hopper_require! |
| Lifecycle | hopper_init!, hopper_close! |
| Dispatch | hopper_register_discs! |
| PDA | hopper_verify_pda! |
| Invariants | hopper_invariant! |
| Manifest | hopper_manifest! |
| Segments | hopper_segment! |
| Pipelines | hopper_validate! |
| Virtual state | hopper_virtual! |
| Compat / ABI | hopper_assert_compatible!, hopper_assert_fingerprint!, const_assert_pod! |
| Cross-program | hopper_interface! |
| Account structs | hopper_accounts! |
Every macro below is #[macro_export]ed and usable from the root of
the hopper-macros crate regardless of the section banner it lives
under. The banners exist only to help readers navigate the file.
Re-exports§
pub use hopper_core;pub use hopper_runtime;pub use hopper_schema;pub use hopper_system;
Macros§
- const_
assert_ pod - Compile-time assertion for safe manual
Podimplementations. - hopper_
accounts - Generate a typed instruction context struct with validated account parsing.
- hopper_
assert_ compatible - Assert that two layout versions have compatible fingerprints.
- hopper_
assert_ fingerprint - Assert that a layout’s fingerprint matches an expected value.
- hopper_
check - Composable account constraint checking.
- hopper_
close - Safely close an account with sentinel protection.
- hopper_
error - Generate sequential error codes.
- hopper_
init - Initialize an account: allocate, assign, zero-init, write header.
- hopper_
interface - Declare a cross-program interface view.
- hopper_
invariant - Invariant checking macro.
- hopper_
layout - Define a zero-copy account layout.
- hopper_
manifest - Generate a layout manifest for schema tooling.
- hopper_
register_ discs - Discriminator registry – compile-time uniqueness enforcement.
- hopper_
require - Require a condition, returning a custom error if false.
- hopper_
segment - Declare a segmented account with typed segments.
- hopper_
validate - Build a validation pipeline declaratively.
- hopper_
verify_ pda - PDA verification with BUMP_OFFSET optimization.
- hopper_
virtual - Declare a multi-account virtual state mapping.