pub struct SchemaRegistry { /* private fields */ }Expand description
Schema version registry with migration graph
Implementations§
Source§impl SchemaRegistry
impl SchemaRegistry
pub fn new() -> Self
Sourcepub fn register_schema(&mut self, schema: SochSchema, version: SchemaVersion)
pub fn register_schema(&mut self, schema: SochSchema, version: SchemaVersion)
Register initial schema version
Sourcepub fn register_migration(
&mut self,
name: impl Into<String>,
migration: Migration,
) -> Result<()>
pub fn register_migration( &mut self, name: impl Into<String>, migration: Migration, ) -> Result<()>
Register a migration between versions
Sourcepub fn register_converter(
&mut self,
converter: fn(&SochValue) -> SochValue,
) -> usize
pub fn register_converter( &mut self, converter: fn(&SochValue) -> SochValue, ) -> usize
Register a custom type converter
Sourcepub fn current_version(&self, name: &str) -> Option<SchemaVersion>
pub fn current_version(&self, name: &str) -> Option<SchemaVersion>
Get current schema version for a name
Sourcepub fn get_schema(
&self,
name: &str,
version: SchemaVersion,
) -> Option<&SochSchema>
pub fn get_schema( &self, name: &str, version: SchemaVersion, ) -> Option<&SochSchema>
Get schema by name and version
Sourcepub fn current_schema(&self, name: &str) -> Option<&SochSchema>
pub fn current_schema(&self, name: &str) -> Option<&SochSchema>
Get current schema by name
Sourcepub fn migrate_row(&self, name: &str, row: VersionedRow) -> Result<VersionedRow>
pub fn migrate_row(&self, name: &str, row: VersionedRow) -> Result<VersionedRow>
Migrate a row from old version to current version
Sourcepub fn stats(&self) -> Arc<EvolutionStats>
pub fn stats(&self) -> Arc<EvolutionStats>
Get evolution statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaRegistry
impl RefUnwindSafe for SchemaRegistry
impl Send for SchemaRegistry
impl Sync for SchemaRegistry
impl Unpin for SchemaRegistry
impl UnwindSafe for SchemaRegistry
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
Mutably borrows from an owned value. Read more
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