Skip to main content

Crate blvm_sdk_macros

Crate blvm_sdk_macros 

Source
Expand description

Procedural macros for BLVM SDK CLI module system.

Attribute Macros§

arg
Parameter attribute: #[arg(long)], #[arg(short = 'o')], #[arg(default = "x")]. Use on CLI handler parameters for named-arg parsing and type coercion.
blvm_module
Attribute macro: #[blvm_module] - marks the main module struct. On struct: #[module(name = "demo", config = DemoConfig)] generates __module_new(config). With migrations = ((1, up_initial), (2, up_add_items_tree)) also generates ModuleMeta impl for run_module_main!(DemoModule). On impl: #[module(name = "demo")] generates cli_spec, dispatch_cli, rpc_method_names, etc.
cli_subcommand
Attribute macro: #[cli_subcommand] or #[cli_subcommand(name = "...")] - on impl block.
command
Attribute macro: #[command(name = "...")] or #[module_cli(name = "...")] - on struct: marks CLI entry point. On impl block: generates cli_spec(). Same attribute works for both.
config
Attribute macro: #[config(name = "...")] or #[module_config(name = "...")] - marks a config struct.
config_env
Field attribute: #[config_env] or #[config_env("ENV_NAME")]. Use with #[module_config(name = "...")] on the struct. Pass-through; the real logic is in module_config which reads this attribute to generate apply_env_overrides().
event_handlers
Attribute macro: #[event_handlers] - on impl block with #on_event methods.
migration
Attribute macro: #[migration(version = N)] or #[migration(version = N, down)].
module
Attribute macro: #[module] or #[blvm_module] - marks the main module struct. With #[module(name = "demo")] on an impl block: generates CLI, RPC, and event dispatch from a single impl (replaces #command, #[rpc_methods], #event_handlers).
module_cli
Attribute macro: #[module_cli(name = "...")] - marks a struct as the module CLI entry point.
module_config
on_event
Attribute macro: #[on_event(NewBlock, NewTransaction, ...)] - marks a method as event handler. Use with #[event_handlers] on the impl block. Pass-through; event_handlers reads this.
rpc_method
Attribute macro: #[rpc_method] or #[rpc_method(name = "...")].
rpc_methods
Attribute macro: #[rpc_methods] - on impl block with #rpc_method methods.

Derive Macros§

ModuleCliSpec
Placeholder derive macro for future use.