Skip to main content

Schema

Struct Schema 

Source
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

Source

pub fn get_type(&self, name: &str) -> Option<Arc<TypeDefinition>>

Source

pub fn relationship_known(&self, name: &str) -> bool

Source

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.

Source

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).

Source

pub fn relationship_manual_authoring(&self, name: &str) -> ManualAuthoring

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.

Source

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.

Source

pub fn mode(&self) -> RelationshipMode

Source

pub fn id(&self) -> (String, Version)

Source

pub fn suggest_type(&self, name: &str) -> Option<String>

Source

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.

Source

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).

Source

pub fn suggest_relationship(&self, name: &str) -> Option<String>

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Schema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.