pub struct MigrationRegistry { /* private fields */ }Expand description
Holds an ordered chain of migrations keyed by source version.
Implementations§
Source§impl MigrationRegistry
impl MigrationRegistry
pub fn new() -> Self
Sourcepub fn register(&mut self, from_version: u32, f: MigrationFn)
pub fn register(&mut self, from_version: u32, f: MigrationFn)
Register a migration from from_version to from_version + 1.
Sourcepub fn migrate(
&self,
data: &mut SaveData,
from: SchemaVersion,
to: SchemaVersion,
) -> Result<(), String>
pub fn migrate( &self, data: &mut SaveData, from: SchemaVersion, to: SchemaVersion, ) -> Result<(), String>
Run the chain of migrations to bring data from from to to.
Sourcepub fn with_builtin_migrations() -> Self
pub fn with_builtin_migrations() -> Self
Build a registry pre-populated with all 10 built-in migrations (v0→v10).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MigrationRegistry
impl RefUnwindSafe for MigrationRegistry
impl Send for MigrationRegistry
impl Sync for MigrationRegistry
impl Unpin for MigrationRegistry
impl UnsafeUnpin for MigrationRegistry
impl UnwindSafe for MigrationRegistry
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.