Function spl_token_2022::extension::alloc_and_serialize
source · pub fn alloc_and_serialize<S: BaseState, V: Default + Extension + Pod>(
account_info: &AccountInfo<'_>,
new_extension: &V,
overwrite: bool
) -> Result<(), ProgramError>
Expand description
Packs a fixed-length extension into a TLV space
This function reallocates the account as needed to accommodate for the change in space.
If the extension already exists, it will overwrite the existing extension
if overwrite
is true
, otherwise it will return an error.
If the extension does not exist, it will reallocate the account and write the extension into the TLV buffer.
NOTE: Since this function deals with fixed-size extensions, it does not
handle decreasing the size of an account’s data buffer, like the function
alloc_and_serialize_variable_len_extension
does.