pub struct Schema {
pub manifest: SchemaManifest,
pub version: Version,
pub types: HashMap<String, Arc<TypeDefinition>>,
}Expand description
A validated, in-memory schema — the product of the loader.
Holds the parsed manifest, the resolved semver version, and the set of
fully-validated type definitions with edge_weights precomputed.
Fields§
§manifest: SchemaManifest§version: Version§types: HashMap<String, Arc<TypeDefinition>>Implementations§
Source§impl Schema
impl Schema
pub fn get_type(&self, name: &str) -> Option<Arc<TypeDefinition>>
pub fn relationship_known(&self, name: &str) -> bool
Sourcepub fn relationship_acyclic(&self, name: &str) -> bool
pub fn relationship_acyclic(&self, name: &str) -> bool
Returns true iff name is declared with acyclic: true in this
schema. Undeclared names resolve to false (permissive): the write
path already rejects undeclared names in strict mode via
relationship_known, and open mode is explicitly opt-in to cycles.
Sourcepub fn type_propagates(&self, source_type: &str, rel_type: &str) -> bool
pub fn type_propagates(&self, source_type: &str, rel_type: &str) -> bool
Returns true iff entities of source_type propagate rel_type
outward — i.e. the type’s propagating_relationships list
declares this rel-type. A propagating-from-source self-loop is a
weight-bomb (the propagation accumulates into the entity that
originated it), so the engine
refuses self-loops on any (source_type, rel_type) pair where this returns true, independent of the
rel-type’s acyclic flag (which governs longer cycles, a
different concern). Unknown source_type returns false
(permissive — the type’s existence is checked elsewhere).
Returns the schema-declared manual-authoring posture for a
rel-type. Unknown names resolve to Allow (permissive — the
validator path already rejects unknown rel-types in strict
mode). The
explicit-author boundary (memstead_relate, memstead_create’s
relations: inline list, memstead_update’s declare_relations)
gates on this; the body-link → relation alias machinery does
NOT — the alias path is the intended way schema-emitted
rel-types (e.g. REFERENCES) appear on entities.
Sourcepub fn relationship_when_to_use(&self, name: &str) -> Option<String>
pub fn relationship_when_to_use(&self, name: &str) -> Option<String>
when_to_use description for a rel-type, returned as the
recovery hint on RELATION_MANUAL_AUTHORING_FORBIDDEN
envelopes. None when the rel-type is unknown or the schema
author didn’t author the field.
pub fn mode(&self) -> RelationshipMode
pub fn id(&self) -> (String, Version)
pub fn suggest_type(&self, name: &str) -> Option<String>
Sourcepub fn relationship_def(&self, name: &str) -> Option<&RelationshipDef>
pub fn relationship_def(&self, name: &str) -> Option<&RelationshipDef>
Look up a relationship definition by name. None for unknown
names; the _default sentinel is reachable but never a real
edge’s rel_type.
Sourcepub fn relationship_cardinality(&self, name: &str) -> Option<Cardinality>
pub fn relationship_cardinality(&self, name: &str) -> Option<Cardinality>
Cardinality hint declared on name. None for unknown names or
for relationships with no declared cardinality (the default —
shape-free).
pub fn suggest_relationship(&self, name: &str) -> Option<String>
Sourcepub fn alias_target_rel_type(&self) -> Option<&str>
pub fn alias_target_rel_type(&self) -> Option<&str>
Schema-level alias_target_rel_type pointer — names the rel-type
that body wiki-links [[target]] should auto-emit as
engine-synthesised relations. None means the schema is opt-out
of alias synthesis (unbacked body wiki-links continue to refuse
with WIKILINK_WITHOUT_RELATION). The loader has already
validated that the named rel-type is declared.
Sourcepub fn cross_mem_entry(
&self,
target_name: &str,
) -> Option<&CrossMemRelationshipEntry>
pub fn cross_mem_entry( &self, target_name: &str, ) -> Option<&CrossMemRelationshipEntry>
Look up the cross-mem entry whose to_schema matches the
target schema’s name. Returns None when this schema declares
no outbound entry for that domain.
Eligibility is name-based: a schema names a domain, and a
version is one iteration of describing it. The target mem’s
pinned version never participates in the match, so a version
bump on the target side cannot invalidate the declaration. The
loader guarantees to_schema is a validated bare schema name,
so plain string equality is exact here.
Sourcepub fn builtin_default() -> Arc<Schema>
pub fn builtin_default() -> Arc<Schema>
Load the embedded default builtin schema.
Backed by the embedded YAML bundle under builtins/schemas/default/
that ships with every binary. Cached via OnceLock so repeated
calls are cheap.