Attribute Macro rpc_toolkit::command
source · [−]#[command]Expand description
#[command(...)]
#[command(cli_only)]-> executed by CLI instead of RPC server (leaf commands only)#[command(rpc_only)]-> no CLI bindings (leaf commands only)#[command(local)]-> executed wherever it was invoked. (By RPC when hit from RPC server, by cli when invoked from CLI)#[command(blocking)]-> run with spawn_blocking if in an async context#[command(about = "About text")]-> Set about text for the command#[command(rename = "new_name")]-> Set the name of the command tonew_namein the RPC and CLI#[command(subcommands(...))]-> Set this as the parent command for the listed subcommands#[command(subcommands(self(self_command_impl)))]-> If no subcommand is provided, call this functionself_command_impl :: Context ctx, Display res, Into<RpcError> err => ctx -> Result<res, err>- note: Display is not required for
resif it has a custom display function that will take it as input - if
self_command_implis async, writeself(self_command_impl(async)) - if
self_command_implis blocking, writeself(self_command_impl(blocking)) - default: require a subcommand if subcommands are specified
#[command(display(custom_display_fn))]-> Use the functioncustom_display_fnto display the command’s result (leaf commands only)custom_display_fn :: res -> ()- note:
resis the type of the decorated command’s output - default:
default_display