pub struct ChainRegistry { /* private fields */ }Expand description
Holds the registered migrators, normalizers, and validators that the chain runner will dispatch through.
Migrators are keyed by from_version (one per integer; duplicates are
rejected at registration). Normalizers are keyed by schema_version,
at most one per version. Validators are keyed by schema_version.
Contiguity (no gaps in the migrator chain) is checked at runner-start
time over the actual range being traversed, not at registration time.
Implementations§
Source§impl ChainRegistry
impl ChainRegistry
pub fn new() -> Self
Sourcepub fn register_migrator(
&mut self,
migrator: Box<dyn Migrator>,
) -> Result<(), MigrationError>
pub fn register_migrator( &mut self, migrator: Box<dyn Migrator>, ) -> Result<(), MigrationError>
Register a migrator. Rejects duplicates and migrators whose
to_version is not exactly from_version + 1.
Sourcepub fn register_normalizer(
&mut self,
normalizer: Box<dyn Normalizer>,
) -> Result<(), MigrationError>
pub fn register_normalizer( &mut self, normalizer: Box<dyn Normalizer>, ) -> Result<(), MigrationError>
Register a normalizer. Rejects duplicates at the same schema version. At most one normalizer per version is supported on purpose: composing multiple normalizers in a stable order is future work and not needed today.
Sourcepub fn register_validator(&mut self, validator: Box<dyn Validator>)
pub fn register_validator(&mut self, validator: Box<dyn Validator>)
Register a validator. Replaces any existing validator at the same schema version (validators are policy-bearing; the latest registered one wins).
Sourcepub fn migrator_for(&self, from: GenomeSchemaVersion) -> Option<&dyn Migrator>
pub fn migrator_for(&self, from: GenomeSchemaVersion) -> Option<&dyn Migrator>
Look up the migrator that consumes genomes at from.
Sourcepub fn normalizer_for(
&self,
version: GenomeSchemaVersion,
) -> Option<&dyn Normalizer>
pub fn normalizer_for( &self, version: GenomeSchemaVersion, ) -> Option<&dyn Normalizer>
Look up the normalizer at version.
Sourcepub fn validator_for(
&self,
version: GenomeSchemaVersion,
) -> Option<&dyn Validator>
pub fn validator_for( &self, version: GenomeSchemaVersion, ) -> Option<&dyn Validator>
Look up the validator at version.
Sourcepub fn run_validator(
&self,
version: GenomeSchemaVersion,
genome: &Value,
) -> ValidationReport
pub fn run_validator( &self, version: GenomeSchemaVersion, genome: &Value, ) -> ValidationReport
Run the validator at version if one is registered, otherwise
return an empty advisory report stamped with that version. Used by
the chain runner so callers always see a consistent shape.
Sourcepub fn migrator_count(&self) -> usize
pub fn migrator_count(&self) -> usize
Number of migrators currently registered.
Sourcepub fn normalizer_count(&self) -> usize
pub fn normalizer_count(&self) -> usize
Number of normalizers currently registered.
Sourcepub fn validator_count(&self) -> usize
pub fn validator_count(&self) -> usize
Number of validators currently registered.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ChainRegistry
impl !UnwindSafe for ChainRegistry
impl Freeze for ChainRegistry
impl Send for ChainRegistry
impl Sync for ChainRegistry
impl Unpin for ChainRegistry
impl UnsafeUnpin for ChainRegistry
Blanket Implementations§
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
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> ⓘ
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> ⓘ
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