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§
Sourcetype Instruction
type Instruction
Program-specific instruction enum.
Required Methods§
Sourcefn program_id(&self) -> Pubkey
fn program_id(&self) -> Pubkey
The program ID.
Sourcefn from_keyed_accounts(
accounts: &[AccountInterface],
) -> Result<Self, Self::Error>
fn from_keyed_accounts( accounts: &[AccountInterface], ) -> Result<Self, Self::Error>
Construct SDK from root account(s).
Sourcefn get_accounts_to_update(&self, ix: &Self::Instruction) -> Vec<AccountToFetch>
fn get_accounts_to_update(&self, ix: &Self::Instruction) -> Vec<AccountToFetch>
Returns pubkeys of accounts needed for an instruction.
Sourcefn update(&mut self, accounts: &[AccountInterface]) -> Result<(), Self::Error>
fn update(&mut self, accounts: &[AccountInterface]) -> Result<(), Self::Error>
Update internal cache with fetched account data.
Sourcefn get_all_specs(&self) -> Vec<AccountSpec<Self::Variant>>
fn get_all_specs(&self) -> Vec<AccountSpec<Self::Variant>>
Get all cached specs.
Sourcefn get_specs_for_instruction(
&self,
ix: &Self::Instruction,
) -> Vec<AccountSpec<Self::Variant>>
fn get_specs_for_instruction( &self, ix: &Self::Instruction, ) -> Vec<AccountSpec<Self::Variant>>
Get specs filtered for a specific instruction.
Provided Methods§
Sourcefn get_cold_specs(&self) -> Vec<AccountSpec<Self::Variant>>
fn get_cold_specs(&self) -> Vec<AccountSpec<Self::Variant>>
Get only cold specs from all cached specs.
Sourcefn get_cold_specs_for_instruction(
&self,
ix: &Self::Instruction,
) -> Vec<AccountSpec<Self::Variant>>
fn get_cold_specs_for_instruction( &self, ix: &Self::Instruction, ) -> Vec<AccountSpec<Self::Variant>>
Get only cold specs for a specific instruction.
Sourcefn needs_loading(&self, ix: &Self::Instruction) -> bool
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.