Skip to main content

ChainRegistry

Struct ChainRegistry 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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.

Source

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).

Source

pub fn migrator_for(&self, from: GenomeSchemaVersion) -> Option<&dyn Migrator>

Look up the migrator that consumes genomes at from.

Source

pub fn normalizer_for( &self, version: GenomeSchemaVersion, ) -> Option<&dyn Normalizer>

Look up the normalizer at version.

Source

pub fn validator_for( &self, version: GenomeSchemaVersion, ) -> Option<&dyn Validator>

Look up the validator at version.

Source

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.

Source

pub fn migrator_count(&self) -> usize

Number of migrators currently registered.

Source

pub fn normalizer_count(&self) -> usize

Number of normalizers currently registered.

Source

pub fn validator_count(&self) -> usize

Number of validators currently registered.

Trait Implementations§

Source§

impl Default for ChainRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more