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: SUnpacked base data
Implementations§
Source§impl<'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 init_extension<V: Extension>(
&mut self,
overwrite: bool,
) -> Result<&mut V, ProgramError>
pub fn init_extension<V: Extension>( &mut self, overwrite: bool, ) -> Result<&mut V, ProgramError>
Packs the default extension data into an open slot if not already found in the
data buffer. If extension is already found in the buffer, it overwrites the existing
extension with the default state if overwrite is set. If extension found, but
overwrite is not set, it returns error.
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.
Trait Implementations§
Source§impl<'a, S: BaseState> BaseStateWithExtensions<S> for StateWithExtensionsMut<'a, S>
impl<'a, S: BaseState> BaseStateWithExtensions<S> for StateWithExtensionsMut<'a, S>
Source§fn get_tlv_data(&self) -> &[u8] ⓘ
fn get_tlv_data(&self) -> &[u8] ⓘ
Source§fn get_extension<V: Extension>(&self) -> Result<&V, ProgramError>
fn get_extension<V: Extension>(&self) -> Result<&V, ProgramError>
Source§fn get_extension_types(&self) -> Result<Vec<ExtensionType>, ProgramError>
fn get_extension_types(&self) -> Result<Vec<ExtensionType>, ProgramError>
Source§fn get_first_extension_type(
&self,
) -> Result<Option<ExtensionType>, ProgramError>
fn get_first_extension_type( &self, ) -> Result<Option<ExtensionType>, ProgramError>
impl<'data, S: PartialEq + BaseState> StructuralPartialEq for StateWithExtensionsMut<'data, S>
Auto Trait Implementations§
impl<'data, S> !UnwindSafe for StateWithExtensionsMut<'data, S>
impl<'data, S> Freeze for StateWithExtensionsMut<'data, S>where
S: Freeze,
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> UnsafeUnpin for StateWithExtensionsMut<'data, S>where
S: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more