pub struct SchemaMigrator { /* private fields */ }Expand description
Schema migrator for backward compatibility [50].
Enables reading old journal entries by migrating them to current schema version.
Implementations§
Source§impl SchemaMigrator
impl SchemaMigrator
Sourcepub fn register<F>(
&mut self,
from: (u16, u16, u16),
to: (u16, u16, u16),
migrate: F,
)
pub fn register<F>( &mut self, from: (u16, u16, u16), to: (u16, u16, u16), migrate: F, )
Register migration between versions.
Sourcepub fn needs_migration(&self, entry: &VersionedEntry) -> bool
pub fn needs_migration(&self, entry: &VersionedEntry) -> bool
Check if entry needs migration.
Sourcepub fn migrate_to_current(&self, entry: &VersionedEntry) -> SimResult<Vec<u8>>
pub fn migrate_to_current(&self, entry: &VersionedEntry) -> SimResult<Vec<u8>>
Migrate entry to current version.
§Errors
Returns error if no migration path exists or migration fails.
Sourcepub const fn current_version(&self) -> (u16, u16, u16)
pub const fn current_version(&self) -> (u16, u16, u16)
Get current version.
Sourcepub fn migration_count(&self) -> usize
pub fn migration_count(&self) -> usize
Get number of registered migrations.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaMigrator
impl !RefUnwindSafe for SchemaMigrator
impl Send for SchemaMigrator
impl Sync for SchemaMigrator
impl Unpin for SchemaMigrator
impl UnsafeUnpin for SchemaMigrator
impl !UnwindSafe for SchemaMigrator
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