Skip to main content

MigrationEdge

Struct MigrationEdge 

Source
pub struct MigrationEdge {
    pub from_epoch: u32,
    pub to_epoch: u32,
    pub migrator: fn(body: &mut [u8]) -> Result<(), ProgramError>,
}
Expand description

One step in a layout’s migration chain.

An edge takes the raw account body (the bytes after the 16-byte Hopper header), mutates them in place to match the new epoch’s shape, and returns Ok(()) on success. The runtime then atomically bumps the header’s schema_epoch to to_epoch under the same mutable borrow.

Migration functions must not call CPIs (no CreateAccount, no Transfer) and must not resize the account (use realloc for that separately). They may read and write arbitrary bytes within the body, which is why the signature takes &mut [u8]. ZeroCopy safety has deliberately been stepped out of because the user is explicitly translating between two different byte layouts.

Fields§

§from_epoch: u32

Epoch the body is expected to be in before this edge runs.

§to_epoch: u32

Epoch the body will be in after this edge runs successfully.

§migrator: fn(body: &mut [u8]) -> Result<(), ProgramError>

In-place mutator. Called exactly once per upgrade sequence.

Implementations§

Source§

impl MigrationEdge

Source

pub const fn is_forward(&self) -> bool

Reject edges that would decrement or stay at the same epoch . migrations always move forward.

Trait Implementations§

Source§

impl Clone for MigrationEdge

Source§

fn clone(&self) -> MigrationEdge

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MigrationEdge

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.