macro_rules! instruction_dispatch {
(
$pid:expr, $accs:expr, $data:expr;
$( $tag:expr => $handler:expr ),+ $(,)?
) => { ... };
}Expand description
Route instruction data to handler functions based on a single-byte tag.
Replaces Anchor’s #[program] proc macro. Reads byte 0 as the
discriminator and dispatches to the matching handler. Returns
InvalidInstructionData for unknown tags.
ⓘ
instruction_dispatch! {
program_id, accounts, instruction_data;
0 => process_init(program_id, accounts, ix),
1 => process_deposit(program_id, accounts, ix),
2 => process_withdraw(program_id, accounts, ix),
}Inside each arm, ix is a SliceCursor positioned after the tag byte.