pub struct MetadataSchema { /* private fields */ }Expand description
Schema for metadata fields.
A schema declares valid keys, their concrete DataType, and whether they
are required. It can validate actual Metadata values and validate that a
MetadataFilter references known fields with compatible operators.
Implementations§
Source§impl MetadataSchema
impl MetadataSchema
Sourcepub fn builder() -> MetadataSchemaBuilder
pub fn builder() -> MetadataSchemaBuilder
Creates a schema builder.
Sourcepub fn field(&self, key: &str) -> Option<&MetadataField>
pub fn field(&self, key: &str) -> Option<&MetadataField>
Returns the field definition for key.
Sourcepub fn field_type(&self, key: &str) -> Option<DataType>
pub fn field_type(&self, key: &str) -> Option<DataType>
Returns the declared data type for key.
Sourcepub fn unknown_field_policy(&self) -> UnknownFieldPolicy
pub fn unknown_field_policy(&self) -> UnknownFieldPolicy
Returns the unknown-field policy.
Sourcepub fn fields(&self) -> impl Iterator<Item = (&str, &MetadataField)>
pub fn fields(&self) -> impl Iterator<Item = (&str, &MetadataField)>
Returns an iterator over schema fields in key-sorted order.
Sourcepub fn validate(&self, meta: &Metadata) -> MetadataResult<()>
pub fn validate(&self, meta: &Metadata) -> MetadataResult<()>
Validates a metadata object against this schema.
§Errors
Returns an error when a required field is missing, a declared field has a different concrete type, or an unknown field is present while the schema rejects unknown fields.
Sourcepub fn validate_filter(&self, filter: &MetadataFilter) -> MetadataResult<()>
pub fn validate_filter(&self, filter: &MetadataFilter) -> MetadataResult<()>
Validates a metadata filter against this schema.
§Errors
Returns an error when the filter references an unknown field, uses a range operator on a non-comparable field, or compares a field with an incompatible value type.
Trait Implementations§
Source§impl Clone for MetadataSchema
impl Clone for MetadataSchema
Source§fn clone(&self) -> MetadataSchema
fn clone(&self) -> MetadataSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more