Skip to main content

MigrationPlan

Struct MigrationPlan 

Source
pub struct MigrationPlan<'a, const N: usize> {
    pub policy: MigrationPolicy,
    pub steps: [MigrationStep<'a>; N],
    pub step_count: usize,
    pub old_size: usize,
    pub new_size: usize,
    pub copy_bytes: usize,
    pub zero_bytes: usize,
    pub backward_readable: bool,
}
Expand description

A generated migration plan between two layout versions.

Contains ordered steps to transform V(N) account data to V(N+1). All steps are stack-allocated to stay no_std/no_alloc.

Fields§

§policy: MigrationPolicy§steps: [MigrationStep<'a>; N]§step_count: usize§old_size: usize

Old total size.

§new_size: usize

New total size.

§copy_bytes: usize

How many bytes must be copied from old to new.

§zero_bytes: usize

How many bytes are newly zero-initialized.

§backward_readable: bool

Whether V(N) code can still parse V(N+1) accounts (prefix-compatible).

Implementations§

Source§

impl<'a, const N: usize> MigrationPlan<'a, N>

Source

pub fn generate(older: &'a LayoutManifest, newer: &'a LayoutManifest) -> Self

Generate a migration plan from two manifests.

Analyzes the field-level diff and produces an ordered list of concrete steps (copy prefix, zero-init new fields, update header).

Source

pub fn len(&self) -> usize

Number of steps in the plan.

Source

pub fn is_empty(&self) -> bool

Whether the plan has no steps.

Source

pub fn requires_data_copy(&self) -> bool

Whether this plan requires data movement (non-trivial migration).

Source

pub fn step(&self, i: usize) -> Option<&MigrationStep<'a>>

Get step by index.

Source

pub fn for_each_step<F: FnMut(usize, &MigrationStep<'a>)>(&self, f: F)

Iterator-style: iterate steps with index.

Trait Implementations§

Source§

impl<'a, const N: usize> Display for MigrationPlan<'a, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, const N: usize> Freeze for MigrationPlan<'a, N>

§

impl<'a, const N: usize> RefUnwindSafe for MigrationPlan<'a, N>

§

impl<'a, const N: usize> Send for MigrationPlan<'a, N>

§

impl<'a, const N: usize> Sync for MigrationPlan<'a, N>

§

impl<'a, const N: usize> Unpin for MigrationPlan<'a, N>

§

impl<'a, const N: usize> UnsafeUnpin for MigrationPlan<'a, N>

§

impl<'a, const N: usize> UnwindSafe for MigrationPlan<'a, N>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.