Skip to main content

MigratingAccount

Struct MigratingAccount 

Source
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>

Source

pub fn from_account( account: &'a AccountView, program_id: &'a Address, ) -> Result<Self, ProgramError>

Construct from an AccountView, validating it holds the From layout.

Source

pub fn old(&self) -> Result<VerifiedAccount<'a, From>, ProgramError>

Read the old layout (immutable).

Source

pub fn old_mut(&self) -> Result<VerifiedAccountMut<'a, From>, ProgramError>

Read the old layout (mutable) for in-place transformation.

Source

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.

Source

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.

Source

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.

Source

pub fn address(&self) -> &Address

The account’s address.

Source

pub fn to_account_view(&self) -> &'a AccountView

The underlying AccountView.

Auto Trait Implementations§

§

impl<'a, From, To> Freeze for MigratingAccount<'a, From, To>

§

impl<'a, From, To> RefUnwindSafe for MigratingAccount<'a, From, To>
where From: RefUnwindSafe, To: RefUnwindSafe,

§

impl<'a, From, To> Send for MigratingAccount<'a, From, To>
where From: Send, To: Send,

§

impl<'a, From, To> Sync for MigratingAccount<'a, From, To>
where From: Sync, To: Sync,

§

impl<'a, From, To> Unpin for MigratingAccount<'a, From, To>
where From: Unpin, To: Unpin,

§

impl<'a, From, To> UnsafeUnpin for MigratingAccount<'a, From, To>

§

impl<'a, From, To> UnwindSafe for MigratingAccount<'a, From, To>
where From: UnwindSafe, To: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.