handle_cmd

Function handle_cmd 

Source
pub fn handle_cmd(cmd: &EpochCmd) -> Result<(), AppError>
Expand description

Public entry point used by efo::main - dispatches to the real handler that lives in crate::world::EpochManager.

§Arguments

  • cmd - The command to execute. This is an enum that represents one of the possible sub-commands for the epoch feature.

§Returns

  • Ok(()) on success.
  • Err(AppError) if any step of the command handling fails.

§Examples

// Create a command to switch to epoch 3.
let cmd = cli_epoch::EpochCmd::Switch(cli_epoch::Switch { target: 3 });
// Execute the command.
let result = handle_cmd(cmd);
assert!(result.is_ok());

The function never panics under normal operation. All errors are reported via the returned Result.