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: u32Epoch the body is expected to be in before this edge runs.
to_epoch: u32Epoch 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
impl MigrationEdge
Sourcepub const fn is_forward(&self) -> bool
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
impl Clone for MigrationEdge
Source§fn clone(&self) -> MigrationEdge
fn clone(&self) -> MigrationEdge
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more