pub trait Migration: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn apply(&self, toml_src: &str) -> Result<MigrationResult, MigrateError>;
}Expand description
A single idempotent config migration step.
Each impl wraps one of the free-standing migrate_* functions and gives it a stable
name used in logs and test assertions. The trait is object-safe so that steps can be
stored in a Vec<Box<dyn Migration + Send + Sync>>.
§Contract for implementors
applymust be idempotent: calling it twice on the same source must return the same output as calling it once.- On a no-op (nothing to migrate),
applyreturns aMigrationResultwithchanged_count == 0.
§Examples
use zeph_config::migrate::{Migration, MIGRATIONS};
// The registry is ordered chronologically; apply each step in sequence.
let mut toml = "[agent]\nname = \"zeph\"\n".to_owned();
for m in MIGRATIONS.iter() {
toml = m.apply(&toml).expect("migration failed").output;
}Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Human-readable identifier used in diagnostics and ordering assertions.
Sourcefn apply(&self, toml_src: &str) -> Result<MigrationResult, MigrateError>
fn apply(&self, toml_src: &str) -> Result<MigrationResult, MigrateError>
Apply this migration step to toml_src.
§Errors
Propagates any MigrateError from the underlying free function.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".