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§
sourcefn valid_account_data(account_data: &[u8]) -> bool
fn valid_account_data(account_data: &[u8]) -> bool
Check if the account data is a valid token account
Provided Methods§
sourcefn unpack_account_owner_unchecked(account_data: &[u8]) -> &Pubkey
fn unpack_account_owner_unchecked(account_data: &[u8]) -> &Pubkey
Call after account length has already been verified to unpack the account owner
sourcefn unpack_account_mint_unchecked(account_data: &[u8]) -> &Pubkey
fn unpack_account_mint_unchecked(account_data: &[u8]) -> &Pubkey
Call after account length has already been verified to unpack the account mint
sourcefn unpack_pubkey_unchecked(account_data: &[u8], offset: usize) -> &Pubkey
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
sourcefn unpack_account_owner(account_data: &[u8]) -> Option<&Pubkey>
fn unpack_account_owner(account_data: &[u8]) -> Option<&Pubkey>
Unpacks an account’s owner from opaque account data.
sourcefn unpack_account_mint(account_data: &[u8]) -> Option<&Pubkey>
fn unpack_account_mint(account_data: &[u8]) -> Option<&Pubkey>
Unpacks an account’s mint from opaque account data.