pub trait MigrationStep:
Codec
+ MaxEncodedLen
+ Default {
const VERSION: u16;
// Required methods
fn max_step_weight() -> Weight;
fn step(&mut self, meter: &mut WeightMeter) -> IsFinished;
// Provided methods
fn integrity_test(max_block_weight: Weight) { ... }
fn pre_upgrade_step() -> Result<Vec<u8>, TryRuntimeError> { ... }
fn post_upgrade_step(_state: Vec<u8>) -> Result<(), TryRuntimeError> { ... }
}
Expand description
A trait that allows to migrate storage from one version to another.
The migration is done in steps. The migration is finished when
step()
returns IsFinished::Yes
.
Required Associated Constants§
Required Methods§
Sourcefn max_step_weight() -> Weight
fn max_step_weight() -> Weight
Returns the maximum weight that can be consumed in a single step.
Sourcefn step(&mut self, meter: &mut WeightMeter) -> IsFinished
fn step(&mut self, meter: &mut WeightMeter) -> IsFinished
Process one step of the migration.
Returns whether the migration is finished.
Provided Methods§
Sourcefn integrity_test(max_block_weight: Weight)
fn integrity_test(max_block_weight: Weight)
Verify that the migration step fits into Cursor
, and that max_step_weight
is not greater
than max_block_weight
.
Sourcefn pre_upgrade_step() -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step() -> Result<Vec<u8>, TryRuntimeError>
Execute some pre-checks prior to running the first step of this migration.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.