pub struct SchemaGraph { /* private fields */ }Expand description
Case-insensitive lookup over a parsed schema’s declarations.
EXPRESS identifiers are case-insensitive, and Part 21 records conventionally
spell entity names in upper case (MYENTITY) while schema sources spell
them in mixed case (MyEntity). Every lookup here folds case so callers can
pass whichever spelling they hold.
Implementations§
Source§impl SchemaGraph
impl SchemaGraph
Sourcepub fn new(parsed: ParsedSchema) -> Self
pub fn new(parsed: ParsedSchema) -> Self
Indexes a parsed schema for querying.
Sourcepub fn from_express(source: &str) -> Self
pub fn from_express(source: &str) -> Self
Parses EXPRESS source and indexes it in one step.
Sourcepub fn entity_count(&self) -> usize
pub fn entity_count(&self) -> usize
How many entity declarations the schema holds.
Sourcepub fn type_count(&self) -> usize
pub fn type_count(&self) -> usize
How many type declarations the schema holds.
Sourcepub fn entity(&self, name: &str) -> Option<&EntityDef>
pub fn entity(&self, name: &str) -> Option<&EntityDef>
The entity declaration for name, if the schema declares one.
Sourcepub fn type_def(&self, name: &str) -> Option<&TypeDef>
pub fn type_def(&self, name: &str) -> Option<&TypeDef>
The type declaration for name, if the schema declares one.
Sourcepub fn entity_names(&self) -> impl Iterator<Item = &str>
pub fn entity_names(&self) -> impl Iterator<Item = &str>
Every entity name the schema declares, in unspecified order.
Callers needing determinism must sort: the underlying map order is deliberately not promised.
Sourcepub fn is_a(&self, name: &str, ancestor: &str) -> bool
pub fn is_a(&self, name: &str, ancestor: &str) -> bool
Whether name is ancestor, or inherits from it.
Reflexive for declared entities, matching EXPRESS subtype semantics where a type belongs to its own subtype set. An entity the schema never declares is not a subtype of anything, including itself – otherwise a typo would silently satisfy every check made against it.
Sourcepub fn supertypes(&self, name: &str) -> Vec<&str>
pub fn supertypes(&self, name: &str) -> Vec<&str>
The supertype chain above name, nearest parent first.
Excludes name itself. Bounded by a fixed depth limit so a malformed
cyclic schema terminates instead of hanging.
Sourcepub fn attributes(&self, name: &str) -> Vec<&Attribute>
pub fn attributes(&self, name: &str) -> Vec<&Attribute>
Every attribute slot in Part 21 positional order, inherited first.
See the module documentation for why this ordering is load-bearing.
Derived redeclarations are included: they keep their inherited
position and are written * in a Part 21 record. Use
EntityDef::is_derived on the owning entity to tell them apart.
Sourcepub fn attribute_names(&self, name: &str) -> Vec<&str>
pub fn attribute_names(&self, name: &str) -> Vec<&str>
Attribute names in positional order.
The bridge a positional-to-named mapping needs: slot i is called
names[i].
Sourcepub fn resolve_defined(&self, name: &str) -> String
pub fn resolve_defined(&self, name: &str) -> String
Resolves a defined type to the base it ultimately aliases.
A chain such as PositiveCount -> Count -> INTEGER resolves to
INTEGER. Returns the final right-hand side; for a declaration that is
not an alias, that is the type’s own name. Bounded like the supertype
walk so a cyclic alias cannot hang.
The right-hand side is returned verbatim, including any aggregate
syntax (LIST [1:?] OF X): discarding it here would throw away the
aggregate fact entirely, and callers that want the base scalar can
match on the text they receive.
Trait Implementations§
Source§impl Clone for SchemaGraph
impl Clone for SchemaGraph
Source§fn clone(&self) -> SchemaGraph
fn clone(&self) -> SchemaGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more