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.

Object Safety§

This trait is not object safe.

Implementors§