pub struct StorageMigration { /* private fields */ }Expand description
Runs schema migrations for a storage subsystem.
Given the current schema version (from version.json) and a target
version, applies each MigrationStep in order.
Implementations§
Source§impl StorageMigration
impl StorageMigration
Sourcepub fn new(steps: Vec<Box<dyn MigrationStep>>, target_version: u32) -> Self
pub fn new(steps: Vec<Box<dyn MigrationStep>>, target_version: u32) -> Self
Create a new migration runner with the given ordered steps.
Sourcepub fn migrate(&self, data_dir: &Path) -> Result<(), StorageError>
pub fn migrate(&self, data_dir: &Path) -> Result<(), StorageError>
Run any necessary migrations for data_dir, updating version.json
after each successful step.
Uses a copy-then-swap strategy: each step operates on a scratch directory, then the result is atomically renamed into place.
§Errors
Returns StorageError::Migration if any step fails.
Sourcepub const fn target_version(&self) -> u32
pub const fn target_version(&self) -> u32
Current target version this runner expects.
Auto Trait Implementations§
impl Freeze for StorageMigration
impl !RefUnwindSafe for StorageMigration
impl Send for StorageMigration
impl Sync for StorageMigration
impl Unpin for StorageMigration
impl UnsafeUnpin for StorageMigration
impl !UnwindSafe for StorageMigration
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