pub struct SchemaRegistry { /* private fields */ }Implementations§
Source§impl SchemaRegistry
impl SchemaRegistry
pub fn new() -> Self
pub fn add_schema(&mut self, schema: Schema)
pub fn get_schema(&self, entity: &str) -> Option<&Schema>
Sourcepub fn validate_entity(&self, entity_name: &str, data: &Value) -> Result<()>
pub fn validate_entity(&self, entity_name: &str, data: &Value) -> Result<()>
§Errors
Returns an error if the entity has a schema and validation fails.
Sourcepub fn apply_defaults(&self, entity_name: &str, data: &mut Value) -> Result<()>
pub fn apply_defaults(&self, entity_name: &str, data: &mut Value) -> Result<()>
§Errors
Returns an error if the entity has a schema and applying defaults fails.
Sourcepub fn persist_schema(
&self,
batch: &mut BatchWriter,
schema: &Schema,
) -> Result<()>
pub fn persist_schema( &self, batch: &mut BatchWriter, schema: &Schema, ) -> Result<()>
§Errors
Returns an error if serialization fails.
Sourcepub fn load_schemas(&mut self, storage: &Storage) -> Result<()>
pub fn load_schemas(&mut self, storage: &Storage) -> Result<()>
§Errors
Returns an error if reading or deserializing schemas fails.
Sourcepub fn validate_fields_exist(
&self,
entity_name: &str,
fields: &[&str],
context: &str,
) -> Result<()>
pub fn validate_fields_exist( &self, entity_name: &str, fields: &[&str], context: &str, ) -> Result<()>
§Errors
Returns SchemaViolation if any field doesn’t exist in the entity’s schema.
pub fn entity_names(&self) -> Vec<String>
pub fn remove_schema(&mut self, batch: &mut BatchWriter, entity: &str)
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 UnsafeUnpin 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