pub struct RuleVersionMigrator { /* private fields */ }Expand description
Registry and executor for rule-set schema migrations.
Steps are registered individually and queried on demand to build a
MigrationPlan. Migration is simulated (no actual rule-set bytes are
transformed; the struct tracks counts and emits warnings for lossy
operations).
Implementations§
Source§impl RuleVersionMigrator
impl RuleVersionMigrator
Sourcepub fn register_step(&mut self, step: MigrationStep)
pub fn register_step(&mut self, step: MigrationStep)
Register a migration step.
Steps may be registered in any order; plan will sort and chain them
as required.
Sourcepub fn plan(
&self,
from: RuleSchemaVersion,
to: RuleSchemaVersion,
) -> Option<MigrationPlan>
pub fn plan( &self, from: RuleSchemaVersion, to: RuleSchemaVersion, ) -> Option<MigrationPlan>
Build an ordered migration plan from from to to.
- If
from == to: returnsSome(MigrationPlan { steps: vec![] }). - If
from < to(upgrade): attempts to find a sequential chain of registered steps that covers every version hop betweenfromandto. - If
from > to(downgrade): attempts the same but in reverse; a downgrade warning is embedded in the first step’s description (the warning is surfaced as aMigrationResult::warningsentry whenmigrateis called). - Returns
Nonewhen no complete path exists.
Sourcepub fn migrate(
&self,
from: RuleSchemaVersion,
to: RuleSchemaVersion,
) -> MigrationResult
pub fn migrate( &self, from: RuleSchemaVersion, to: RuleSchemaVersion, ) -> MigrationResult
Execute a migration from from to to and return the result.
The migration is simulated: no actual rule-set data is mutated. The
result carries counts of applied steps and transforms, plus any
warnings generated (e.g. for ConvertType or downgrade operations).
Sourcepub fn registered_paths(&self) -> Vec<(RuleSchemaVersion, RuleSchemaVersion)>
pub fn registered_paths(&self) -> Vec<(RuleSchemaVersion, RuleSchemaVersion)>
Return all registered (from, to) version pairs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RuleVersionMigrator
impl RefUnwindSafe for RuleVersionMigrator
impl Send for RuleVersionMigrator
impl Sync for RuleVersionMigrator
impl Unpin for RuleVersionMigrator
impl UnsafeUnpin for RuleVersionMigrator
impl UnwindSafe for RuleVersionMigrator
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more