command

Attribute Macro command 

Source
#[command]
Expand description

Attribute macro #[command] for generating FFI bindings and client helpers on a struct or enum that implements CommandHandler.

§Parameters

  • attr: TokenStream of attribute arguments (e.g. program = "foo", name = "bar").
  • item: TokenStream of the annotated item (must be a struct or enum).

§Behavior

  1. Parses item into a syn::Item.
  2. Parses attr into our CommandArgs helper (extracting program and name).
  3. If item is a struct or enum, obtains its identifier (ident), builds/upgrades the program metadata via create_program_metadata(&args.program), and calls process_program_command(...) to emit the expanded FFI binding and metadata embedding.
  4. If used on any other item, emits a compile error pointing at the original span, instructing that #[command] only applies to types implementing CommandHandler.