pub trait MigrateSequence: Sealed {
const VERSION_RANGE: (u16, u16);
// Required methods
fn new(version: StorageVersion) -> Cursor;
fn steps(
version: StorageVersion,
cursor: &[u8],
meter: &mut WeightMeter,
) -> StepResult;
fn integrity_test(max_block_weight: Weight);
// Provided methods
fn pre_upgrade_step(
_version: StorageVersion,
) -> Result<Vec<u8>, TryRuntimeError> { ... }
fn post_upgrade_step(
_version: StorageVersion,
_state: Vec<u8>,
) -> Result<(), TryRuntimeError> { ... }
fn is_upgrade_supported(
in_storage: StorageVersion,
target: StorageVersion,
) -> bool { ... }
}
Expand description
Defines a sequence of migrations.
The sequence must be defined by a tuple of migrations, each of which must implement the
MigrationStep
trait. Migrations must be ordered by their versions with no gaps.
Required Associated Constants§
Sourceconst VERSION_RANGE: (u16, u16)
const VERSION_RANGE: (u16, u16)
Returns the range of versions that this migrations sequence can handle. Migrations must be ordered by their versions with no gaps.
The following code will fail to compile:
let _ = <(NoopMigration<1>, NoopMigration<3>)>::VERSION_RANGE;
The following code will compile:
let _ = <(NoopMigration<1>, NoopMigration<2>)>::VERSION_RANGE;
Required Methods§
Sourcefn steps(
version: StorageVersion,
cursor: &[u8],
meter: &mut WeightMeter,
) -> StepResult
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
Execute the migration step until the available weight is consumed.
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
.
Provided Methods§
fn pre_upgrade_step( _version: StorageVersion, ) -> Result<Vec<u8>, TryRuntimeError>
fn post_upgrade_step( _version: StorageVersion, _state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Sourcefn is_upgrade_supported(
in_storage: StorageVersion,
target: StorageVersion,
) -> bool
fn is_upgrade_supported( in_storage: StorageVersion, target: StorageVersion, ) -> bool
Returns whether migrating from in_storage
to target
is supported.
A migration is supported if VERSION_RANGE
is (in_storage + 1, target).
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.
Implementations on Foreign Types§
Source§impl MigrateSequence for ()
impl MigrateSequence for ()
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep> MigrateSequence for (TupleElement0,)
impl<TupleElement0: MigrationStep> MigrateSequence for (TupleElement0,)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1)
impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2)
impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3)
impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep, TupleElement7: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep, TupleElement7: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep, TupleElement7: MigrationStep, TupleElement8: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8)
impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep, TupleElement7: MigrationStep, TupleElement8: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.
const VERSION_RANGE: (u16, u16) = _
fn new(version: StorageVersion) -> Cursor
fn steps( version: StorageVersion, cursor: &[u8], meter: &mut WeightMeter, ) -> StepResult
fn integrity_test(max_block_weight: Weight)
Source§impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep, TupleElement7: MigrationStep, TupleElement8: MigrationStep, TupleElement9: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9)
impl<TupleElement0: MigrationStep, TupleElement1: MigrationStep, TupleElement2: MigrationStep, TupleElement3: MigrationStep, TupleElement4: MigrationStep, TupleElement5: MigrationStep, TupleElement6: MigrationStep, TupleElement7: MigrationStep, TupleElement8: MigrationStep, TupleElement9: MigrationStep> MigrateSequence for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9)
Source§fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
fn pre_upgrade_step(version: StorageVersion) -> Result<Vec<u8>, TryRuntimeError>
Execute the pre-checks of the step associated with this version.
Source§fn post_upgrade_step(
version: StorageVersion,
state: Vec<u8>,
) -> Result<(), TryRuntimeError>
fn post_upgrade_step( version: StorageVersion, state: Vec<u8>, ) -> Result<(), TryRuntimeError>
Execute the post-checks of the step associated with this version.