pub trait Resizable: TokenMetadataAccount + BorshSerialize {
    // Required method
    fn from_bytes(data: &[u8]) -> Result<Self, ProgramError>;

    // Provided method
    fn save<'a>(
        &self,
        account_info: &'a AccountInfo<'a>,
        payer_info: &'a AccountInfo<'a>,
        system_program_info: &'a AccountInfo<'a>
    ) -> Result<(), ProgramError> { ... }
}
Expand description

Trait for resizable accounts.

Implementing this trait for a type will automatically allow the use of the save method, which can modify the size of an account.

A type implementing this trait must specify the from_bytes method, since an account can have variable size.

Required Methods§

source

fn from_bytes(data: &[u8]) -> Result<Self, ProgramError>

Deserializes the struct data from the specified byte array.

In most cases this will perform a custom deserialization since the size of the stored byte array (account) can change.

Provided Methods§

source

fn save<'a>( &self, account_info: &'a AccountInfo<'a>, payer_info: &'a AccountInfo<'a>, system_program_info: &'a AccountInfo<'a> ) -> Result<(), ProgramError>

Saves the information to the specified account, resizing the account if needed.

The account size can either increase or decrease depending on whether the account size matches the struct size or not.

Implementors§