pub struct MigratingAccount<'a, From, To>{ /* private fields */ }Expand description
An account undergoing migration from layout From to layout To.
Construction validates that the account currently holds a From layout.
After calling migrate_append() or performing manual migration, the
caller can access the To layout via into_latest().
Implementations§
Source§impl<'a, From, To> MigratingAccount<'a, From, To>
impl<'a, From, To> MigratingAccount<'a, From, To>
Sourcepub fn from_account(
account: &'a AccountView,
program_id: &'a Address,
) -> Result<Self, ProgramError>
pub fn from_account( account: &'a AccountView, program_id: &'a Address, ) -> Result<Self, ProgramError>
Construct from an AccountView, validating it holds the From layout.
Sourcepub fn old(&self) -> Result<VerifiedAccount<'a, From>, ProgramError>
pub fn old(&self) -> Result<VerifiedAccount<'a, From>, ProgramError>
Read the old layout (immutable).
Sourcepub fn old_mut(&self) -> Result<VerifiedAccountMut<'a, From>, ProgramError>
pub fn old_mut(&self) -> Result<VerifiedAccountMut<'a, From>, ProgramError>
Read the old layout (mutable) for in-place transformation.
Sourcepub fn into_latest(&self) -> Result<VerifiedAccountMut<'a, To>, ProgramError>
pub fn into_latest(&self) -> Result<VerifiedAccountMut<'a, To>, ProgramError>
Access the new layout after migration has been applied.
The caller must have already performed the migration (realloc + header
update) before calling this. The header is re-validated against To.
Sourcepub fn migrate_append(&self, payer: &AccountView) -> Result<(), ProgramError>
pub fn migrate_append(&self, payer: &AccountView) -> Result<(), ProgramError>
Perform an append migration in-place using the existing migration helper.
After this returns successfully, into_latest() will succeed.
Sourcepub fn migration_kind(&self) -> MigrationKind
pub fn migration_kind(&self) -> MigrationKind
Determine what kind of migration is needed.
Append migration is valid when the new layout is strictly larger and shares the same base prefix as the old layout.
Sourcepub fn to_account_view(&self) -> &'a AccountView
pub fn to_account_view(&self) -> &'a AccountView
The underlying AccountView.