use borsh::BorshDeserialize;
use cruiser::account_argument::AccountArgument;
use crate::account_argument::{FromAccounts, ValidateArgument};
use crate::{CruiserResult, Pubkey};
pub trait Instruction<AI>: Sized {
type Accounts;
type Data;
}
pub trait InstructionProcessor<AI, I: Instruction<AI>>
where
I::Data: BorshDeserialize,
I::Accounts: AccountArgument<AccountInfo = AI>
+ FromAccounts<Self::FromAccountsData>
+ ValidateArgument<Self::ValidateData>,
{
type FromAccountsData;
type ValidateData;
type InstructionData;
fn data_to_instruction_arg(
data: I::Data,
) -> CruiserResult<(
Self::FromAccountsData,
Self::ValidateData,
Self::InstructionData,
)>;
fn process(
program_id: &Pubkey,
data: Self::InstructionData,
accounts: &mut I::Accounts,
) -> CruiserResult<()>;
}