Struct spl_token_2022::extension::StateWithExtensionsMut
source · [−]pub struct StateWithExtensionsMut<'data, S: BaseState> {
pub base: S,
/* private fields */
}
Expand description
Encapsulates mutable base state data (mint or account) with possible extensions
Fields
base: S
Unpacked base data
Implementations
sourceimpl<'data, S: BaseState> StateWithExtensionsMut<'data, S>
impl<'data, S: BaseState> StateWithExtensionsMut<'data, S>
sourcepub fn unpack(input: &'data mut [u8]) -> Result<Self, ProgramError>
pub fn unpack(input: &'data mut [u8]) -> Result<Self, ProgramError>
Unpack base state, leaving the extension data as a mutable slice
Fails if the base state is not initialized.
sourcepub fn unpack_uninitialized(
input: &'data mut [u8]
) -> Result<Self, ProgramError>
pub fn unpack_uninitialized(
input: &'data mut [u8]
) -> Result<Self, ProgramError>
Unpack an uninitialized base state, leaving the extension data as a mutable slice
Fails if the base state has already been initialized.
sourcepub fn get_extension_mut<V: Extension>(
&mut self
) -> Result<&mut V, ProgramError>
pub fn get_extension_mut<V: Extension>(
&mut self
) -> Result<&mut V, ProgramError>
Unpack a portion of the TLV data as the desired type that allows modifying the type
sourcepub fn get_extension<V: Extension>(&self) -> Result<&V, ProgramError>
pub fn get_extension<V: Extension>(&self) -> Result<&V, ProgramError>
Unpack a portion of the TLV data as the desired type
sourcepub fn init_extension<V: Extension>(&mut self) -> Result<&mut V, ProgramError>
pub fn init_extension<V: Extension>(&mut self) -> Result<&mut V, ProgramError>
Packs the default extension data into an open slot if not already found in the data buffer, otherwise overwrites the existing extension with the default state
sourcepub fn init_account_extension_from_type(
&mut self,
extension_type: ExtensionType
) -> Result<(), ProgramError>
pub fn init_account_extension_from_type(
&mut self,
extension_type: ExtensionType
) -> Result<(), ProgramError>
If extension_type
is an Account-associated ExtensionType that requires initialization on
InitializeAccount, this method packs the default relevant Extension of an ExtensionType
into an open slot if not already found in the data buffer, otherwise overwrites the
existing extension with the default state. For all other ExtensionTypes, this is a no-op.
sourcepub fn init_account_type(&mut self) -> Result<(), ProgramError>
pub fn init_account_type(&mut self) -> Result<(), ProgramError>
Write the account type into the buffer, done during the base state initialization Noops if there is no room for an extension in the account, needed for pure base mints / accounts.
sourcepub fn get_extension_types(&self) -> Result<Vec<ExtensionType>, ProgramError>
pub fn get_extension_types(&self) -> Result<Vec<ExtensionType>, ProgramError>
Iterates through the TLV entries, returning only the types
Trait Implementations
sourceimpl<'data, S: Debug + BaseState> Debug for StateWithExtensionsMut<'data, S>
impl<'data, S: Debug + BaseState> Debug for StateWithExtensionsMut<'data, S>
sourceimpl<'data, S: PartialEq + BaseState> PartialEq<StateWithExtensionsMut<'data, S>> for StateWithExtensionsMut<'data, S>
impl<'data, S: PartialEq + BaseState> PartialEq<StateWithExtensionsMut<'data, S>> for StateWithExtensionsMut<'data, S>
sourcefn eq(&self, other: &StateWithExtensionsMut<'data, S>) -> bool
fn eq(&self, other: &StateWithExtensionsMut<'data, S>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &StateWithExtensionsMut<'data, S>) -> bool
fn ne(&self, other: &StateWithExtensionsMut<'data, S>) -> bool
This method tests for !=
.
impl<'data, S: BaseState> StructuralPartialEq for StateWithExtensionsMut<'data, S>
Auto Trait Implementations
impl<'data, S> RefUnwindSafe for StateWithExtensionsMut<'data, S> where
S: RefUnwindSafe,
impl<'data, S> Send for StateWithExtensionsMut<'data, S> where
S: Send,
impl<'data, S> Sync for StateWithExtensionsMut<'data, S> where
S: Sync,
impl<'data, S> Unpin for StateWithExtensionsMut<'data, S> where
S: Unpin,
impl<'data, S> !UnwindSafe for StateWithExtensionsMut<'data, S>
Blanket Implementations
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more