pub struct Schema { /* private fields */ }Expand description
A schema: a root reference plus an environment of named records.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn new(
root: Ref,
env: IndexMap<String, Record>,
) -> Result<Self, SchemaError>
pub fn new( root: Ref, env: IndexMap<String, Record>, ) -> Result<Self, SchemaError>
Builds a schema and immediately checks every Ref (the root’s, and
every field’s) resolves within env – mirrors Python’s
Schema.__init__ calling check_refs() unconditionally. Also
enforces S-3 (omnist-spec docs/03-schema-model.md): no record may be
named after a scalar keyword or any, since a bare name in type
position always resolves to the builtin first and such a record could
never be referenced. osd.rs’s parser already enforces this; this is
the same check at the builder-API surface (omnist-rs#76).
Sourcepub fn env(&self) -> &IndexMap<String, Record>
pub fn env(&self) -> &IndexMap<String, Record>
Map of named records comprising the schema environment.
Sourcepub fn resolve(&self, ty: &FieldType) -> Resolved<'_>
pub fn resolve(&self, ty: &FieldType) -> Resolved<'_>
A bare Scalar resolves to itself; a Ref is a single environment
lookup – check_refs already guarantees every Ref resolves, so
this never errors once a Schema exists.
Sourcepub fn validate(&self, cursor: &Cursor<'_>) -> ValidationResult
pub fn validate(&self, cursor: &Cursor<'_>) -> ValidationResult
Validates cursor (and everything beneath it) against this schema’s
root type, collecting every problem found rather than stopping at
the first.
Trait Implementations§
impl Eq for Schema
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.