cruiser/traits/
instruction.rs1use borsh::BorshDeserialize;
4use cruiser::account_argument::AccountArgument;
5
6use crate::account_argument::{FromAccounts, ValidateArgument};
7use crate::{CruiserResult, Pubkey};
8
9pub trait Instruction<AI>: Sized {
11 type Accounts;
13 type Data;
15}
16
17pub trait InstructionProcessor<AI, I: Instruction<AI>>
19where
20 I::Data: BorshDeserialize,
21 I::Accounts: AccountArgument<AccountInfo = AI>
22 + FromAccounts<Self::FromAccountsData>
23 + ValidateArgument<Self::ValidateData>,
24{
25 type FromAccountsData;
27 type ValidateData;
29 type InstructionData;
31
32 fn data_to_instruction_arg(
34 data: I::Data,
35 ) -> CruiserResult<(
36 Self::FromAccountsData,
37 Self::ValidateData,
38 Self::InstructionData,
39 )>;
40
41 fn process(
43 program_id: &Pubkey,
44 data: Self::InstructionData,
45 accounts: &mut I::Accounts,
46 ) -> CruiserResult<()>;
47}