pub trait SolanaAccount: BorshSerialize + BorshDeserialize {
    // Required method
    fn key() -> Key;

    // Provided methods
    fn from_account_info(
        account: &AccountInfo<'_>
    ) -> Result<Self, ProgramError> { ... }
    fn to_account_data(&self, account: &AccountInfo<'_>) -> ProgramResult { ... }
}
Expand description

A trait implementing generic functions required by all accounts on Solana.

Required Methods§

source

fn key() -> Key

Get the Key for this Account. This key is to be stored in the first byte of the Account data.

Provided Methods§

source

fn from_account_info(account: &AccountInfo<'_>) -> Result<Self, ProgramError>

BorshDeserialize the AccountInfo into the Rust data structure.

source

fn to_account_data(&self, account: &AccountInfo<'_>) -> ProgramResult

BorshSerialize the Rust data structure into the Account data.

Implementors§