Trait kaptn_lang::spl_token::BaseStateWithExtensions

source ·
pub trait BaseStateWithExtensions<S>
where S: BaseState,
{ // Required method fn get_tlv_data(&self) -> &[u8] ⓘ; // Provided methods fn get_extension_bytes<V>(&self) -> Result<&[u8], ProgramError> where V: Extension { ... } fn get_extension<V>(&self) -> Result<&V, ProgramError> where V: Extension + Pod { ... } fn get_variable_len_extension<V>(&self) -> Result<V, ProgramError> where V: Extension + VariableLenPack { ... } fn get_extension_types(&self) -> Result<Vec<ExtensionType>, ProgramError> { ... } fn get_first_extension_type( &self, ) -> Result<Option<ExtensionType>, ProgramError> { ... } fn try_get_account_len(&self) -> Result<usize, ProgramError> { ... } fn try_get_new_account_len<V>(&self) -> Result<usize, ProgramError> where V: Extension + Pod { ... } fn try_get_new_account_len_for_variable_len_extension<V>( &self, new_extension: &V, ) -> Result<usize, ProgramError> where V: Extension + VariableLenPack { ... } }
Expand description

Trait for base state with extension

Required Methods§

source

fn get_tlv_data(&self) -> &[u8] ⓘ

Get the buffer containing all extension data

Provided Methods§

source

fn get_extension_bytes<V>(&self) -> Result<&[u8], ProgramError>
where V: Extension,

Fetch the bytes for a TLV entry

source

fn get_extension<V>(&self) -> Result<&V, ProgramError>
where V: Extension + Pod,

Unpack a portion of the TLV data as the desired type

source

fn get_variable_len_extension<V>(&self) -> Result<V, ProgramError>

Unpacks a portion of the TLV data as the desired variable-length type

source

fn get_extension_types(&self) -> Result<Vec<ExtensionType>, ProgramError>

Iterates through the TLV entries, returning only the types

source

fn get_first_extension_type( &self, ) -> Result<Option<ExtensionType>, ProgramError>

Get just the first extension type, useful to track mixed initializations

source

fn try_get_account_len(&self) -> Result<usize, ProgramError>

Get the total number of bytes used by TLV entries and the base type

source

fn try_get_new_account_len<V>(&self) -> Result<usize, ProgramError>
where V: Extension + Pod,

Calculate the new expected size if the state allocates the given fixed-length extension instance. If the state already has the extension, the resulting account length will be unchanged.

source

fn try_get_new_account_len_for_variable_len_extension<V>( &self, new_extension: &V, ) -> Result<usize, ProgramError>

Calculate the new expected size if the state allocates the given variable-length extension instance.

Object Safety§

This trait is not object safe.

Implementors§