pub struct SchemaBuilder { /* private fields */ }Expand description
Implementations§
Source§impl SchemaBuilder
impl SchemaBuilder
Sourcepub fn vertex(
self,
id: &str,
kind: &str,
nsid: Option<&str>,
) -> Result<Self, SchemaError>
pub fn vertex( self, id: &str, kind: &str, nsid: Option<&str>, ) -> Result<Self, SchemaError>
Add a vertex to the schema.
§Errors
Returns SchemaError::DuplicateVertex if a vertex with the same ID
already exists, or SchemaError::UnknownVertexKind if the kind is
not recognized by the protocol.
Sourcepub fn edge(
self,
src: &str,
tgt: &str,
kind: &str,
name: Option<&str>,
) -> Result<Self, SchemaError>
pub fn edge( self, src: &str, tgt: &str, kind: &str, name: Option<&str>, ) -> Result<Self, SchemaError>
Add a binary edge to the schema.
Validates that:
- Both
srcandtgtvertices exist - The edge kind is recognized by the protocol
- The source and target vertex kinds satisfy the edge rule
§Errors
Returns SchemaError::VertexNotFound, SchemaError::UnknownEdgeKind,
SchemaError::InvalidEdgeSource, or SchemaError::InvalidEdgeTarget.
Sourcepub fn hyper_edge(
self,
id: &str,
kind: &str,
sig: HashMap<String, String>,
parent: &str,
) -> Result<Self, SchemaError>
pub fn hyper_edge( self, id: &str, kind: &str, sig: HashMap<String, String>, parent: &str, ) -> Result<Self, SchemaError>
Add a hyper-edge to the schema.
§Errors
Returns SchemaError::DuplicateHyperEdge if a hyper-edge with the
same ID already exists, or SchemaError::VertexNotFound if any
vertex in the signature is missing.
Sourcepub fn constraint(self, vertex: &str, sort: &str, value: &str) -> Self
pub fn constraint(self, vertex: &str, sort: &str, value: &str) -> Self
Add a constraint to a vertex.
Constraints are not validated during building; use validate
to check them against the protocol’s constraint sorts.
Sourcepub fn required(self, vertex: &str, edges: Vec<Edge>) -> Self
pub fn required(self, vertex: &str, edges: Vec<Edge>) -> Self
Declare required edges for a vertex.
Sourcepub fn coercion(
self,
source_kind: &str,
target_kind: &str,
spec: CoercionSpec,
) -> Self
pub fn coercion( self, source_kind: &str, target_kind: &str, spec: CoercionSpec, ) -> Self
Add a coercion specification for a (source_kind, target_kind) pair.
Sourcepub fn default_expr(self, vertex_id: &str, expr: Expr) -> Self
pub fn default_expr(self, vertex_id: &str, expr: Expr) -> Self
Add a default value expression for a vertex.
Sourcepub fn policy(self, sort_name: &str, expr: Expr) -> Self
pub fn policy(self, sort_name: &str, expr: Expr) -> Self
Add a conflict resolution policy expression for a sort.
Sourcepub fn build(self) -> Result<Schema, SchemaError>
pub fn build(self) -> Result<Schema, SchemaError>
Consume the builder and produce a validated Schema with
precomputed adjacency indices.
§Errors
Returns SchemaError::EmptySchema if no vertices were added.