LightProgramInterface

Trait LightProgramInterface 

Source
pub trait LightProgramInterface: Sized {
    type Variant: Pack + Clone + Debug;
    type Instruction;
    type Error: Error;

    // Required methods
    fn program_id(&self) -> Pubkey;
    fn from_keyed_accounts(
        accounts: &[AccountInterface],
    ) -> Result<Self, Self::Error>;
    fn get_accounts_to_update(
        &self,
        ix: &Self::Instruction,
    ) -> Vec<AccountToFetch>;
    fn update(
        &mut self,
        accounts: &[AccountInterface],
    ) -> Result<(), Self::Error>;
    fn get_all_specs(&self) -> Vec<AccountSpec<Self::Variant>>;
    fn get_specs_for_instruction(
        &self,
        ix: &Self::Instruction,
    ) -> Vec<AccountSpec<Self::Variant>>;

    // Provided methods
    fn get_cold_specs(&self) -> Vec<AccountSpec<Self::Variant>> { ... }
    fn get_cold_specs_for_instruction(
        &self,
        ix: &Self::Instruction,
    ) -> Vec<AccountSpec<Self::Variant>> { ... }
    fn needs_loading(&self, ix: &Self::Instruction) -> bool { ... }
}
Expand description

Trait for programs to give clients a unified API to load cold program accounts.

Required Associated Types§

Source

type Variant: Pack + Clone + Debug

The program’s interface account variant enum.

Source

type Instruction

Program-specific instruction enum.

Source

type Error: Error

Error type for SDK operations.

Required Methods§

Source

fn program_id(&self) -> Pubkey

The program ID.

Source

fn from_keyed_accounts( accounts: &[AccountInterface], ) -> Result<Self, Self::Error>

Construct SDK from root account(s).

Source

fn get_accounts_to_update(&self, ix: &Self::Instruction) -> Vec<AccountToFetch>

Returns pubkeys of accounts needed for an instruction.

Source

fn update(&mut self, accounts: &[AccountInterface]) -> Result<(), Self::Error>

Update internal cache with fetched account data.

Source

fn get_all_specs(&self) -> Vec<AccountSpec<Self::Variant>>

Get all cached specs.

Source

fn get_specs_for_instruction( &self, ix: &Self::Instruction, ) -> Vec<AccountSpec<Self::Variant>>

Get specs filtered for a specific instruction.

Provided Methods§

Source

fn get_cold_specs(&self) -> Vec<AccountSpec<Self::Variant>>

Get only cold specs from all cached specs.

Source

fn get_cold_specs_for_instruction( &self, ix: &Self::Instruction, ) -> Vec<AccountSpec<Self::Variant>>

Get only cold specs for a specific instruction.

Source

fn needs_loading(&self, ix: &Self::Instruction) -> bool

Check if any accounts for this instruction are cold.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§