Trait SteppedMigration

Source
pub trait SteppedMigration {
    type Cursor: FullCodec + MaxEncodedLen;
    type Identifier: FullCodec + MaxEncodedLen;

    // Required methods
    fn id() -> Self::Identifier;
    fn step(
        cursor: Option<Self::Cursor>,
        meter: &mut WeightMeter,
    ) -> Result<Option<Self::Cursor>, SteppedMigrationError>;

    // Provided methods
    fn max_steps() -> Option<u32> { ... }
    fn transactional_step(
        cursor: Option<Self::Cursor>,
        meter: &mut WeightMeter,
    ) -> Result<Option<Self::Cursor>, SteppedMigrationError> { ... }
}
Expand description

A migration that can proceed in multiple steps.

Required Associated Types§

Source

type Cursor: FullCodec + MaxEncodedLen

The cursor type that stores the progress (aka. state) of this migration.

Source

type Identifier: FullCodec + MaxEncodedLen

The unique identifier type of this migration.

Required Methods§

Source

fn id() -> Self::Identifier

The unique identifier of this migration.

If two migrations have the same identifier, then they are assumed to be identical.

Source

fn step( cursor: Option<Self::Cursor>, meter: &mut WeightMeter, ) -> Result<Option<Self::Cursor>, SteppedMigrationError>

Try to migrate as much as possible with the given weight.

ANY STORAGE CHANGES MUST BE ROLLED-BACK BY THE CALLER UPON ERROR. This is necessary since the caller cannot return a cursor in the error case. Self::transactional_step is provided as convenience for a caller. A cursor of None implies that the migration is at its end. A migration that once returned Nonce is guaranteed to never be called again.

Provided Methods§

Source

fn max_steps() -> Option<u32>

The maximum number of steps that this migration can take.

This can be used to enforce progress and prevent migrations becoming stuck forever. A migration that exceeds its max steps is treated as failed. None means that there is no limit.

Source

fn transactional_step( cursor: Option<Self::Cursor>, meter: &mut WeightMeter, ) -> Result<Option<Self::Cursor>, SteppedMigrationError>

Same as Self::step, but rolls back pending changes in the error case.

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.

Implementors§