pub struct MigrationChain<S> { /* private fields */ }Expand description
A chain of migrations that can upgrade state through multiple versions.
§Design
The migration chain executes migrations in sequence, starting from the stored version and ending at the current version. Each step increments the version by exactly one.
§Example
ⓘ
let mut chain = MigrationChain::<FinalState>::new();
chain.register(Box::new(V1ToV2Migration));
chain.register(Box::new(V2ToV3Migration));
// Migrate from v1 to v3 (current)
let result = chain.migrate_to_current(v1_state, 1, 3);Implementations§
Source§impl<S: 'static> MigrationChain<S>
impl<S: 'static> MigrationChain<S>
Sourcepub fn register(&mut self, migration: Box<dyn ErasedMigration<S>>)
pub fn register(&mut self, migration: Box<dyn ErasedMigration<S>>)
Register a migration step.
§Panics
Panics if a migration for the same from_version is already registered.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for MigrationChain<S>
impl<S> !RefUnwindSafe for MigrationChain<S>
impl<S> Send for MigrationChain<S>
impl<S> Sync for MigrationChain<S>
impl<S> Unpin for MigrationChain<S>
impl<S> UnsafeUnpin for MigrationChain<S>
impl<S> !UnwindSafe for MigrationChain<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more