spl_token::state

Trait GenericTokenAccount

Source
pub trait GenericTokenAccount {
    // Required method
    fn valid_account_data(account_data: &[u8]) -> bool;

    // Provided methods
    fn unpack_account_owner_unchecked(account_data: &[u8]) -> &Pubkey { ... }
    fn unpack_account_mint_unchecked(account_data: &[u8]) -> &Pubkey { ... }
    fn unpack_pubkey_unchecked(account_data: &[u8], offset: usize) -> &Pubkey { ... }
    fn unpack_account_owner(account_data: &[u8]) -> Option<&Pubkey> { ... }
    fn unpack_account_mint(account_data: &[u8]) -> Option<&Pubkey> { ... }
}
Expand description

A trait for token Account structs to enable efficiently unpacking various fields without unpacking the complete state.

Required Methods§

Source

fn valid_account_data(account_data: &[u8]) -> bool

Check if the account data is a valid token account

Provided Methods§

Source

fn unpack_account_owner_unchecked(account_data: &[u8]) -> &Pubkey

Call after account length has already been verified to unpack the account owner

Source

fn unpack_account_mint_unchecked(account_data: &[u8]) -> &Pubkey

Call after account length has already been verified to unpack the account mint

Source

fn unpack_pubkey_unchecked(account_data: &[u8], offset: usize) -> &Pubkey

Call after account length has already been verified to unpack a Pubkey at the specified offset. Panics if account_data.len() is less than PUBKEY_BYTES

Source

fn unpack_account_owner(account_data: &[u8]) -> Option<&Pubkey>

Unpacks an account’s owner from opaque account data.

Source

fn unpack_account_mint(account_data: &[u8]) -> Option<&Pubkey>

Unpacks an account’s mint from opaque account data.

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§