panproto-inst
Instance representation for panproto.
This crate provides three models for concrete data instances that conform to schemas defined via panproto-schema: tree-shaped W-type instances, relational set-valued functor instances, and graph-shaped instances. All three are unified under the Instance enum. The crate also handles JSON serialization, validation, and the full adjoint triple of instance transformations (restrict, extend, and right Kan extension).
API
| Item | Description |
|---|---|
WInstance |
Tree-shaped (W-type) instance with nodes, arcs, and hyper-edge fans |
FInstance |
Relational (set-valued functor) instance with tables and foreign keys |
GInstance |
Graph-shaped instance with nodes and edges (cycles allowed, no root) |
Instance |
Unified enum wrapping all three instance shapes |
Node |
Metadata for a W-type instance node (anchor, value, position, annotations) |
Value / FieldPresence |
Leaf values and field presence tracking |
Fan |
Hyper-edge fan representation |
parse_json / to_json |
Schema-guided JSON serialization round-trip |
validate_wtype |
Axiom checking (I1–I7) for W-type instances |
wtype_restrict |
5-step restrict pipeline (ΔF) for W-type instances |
wtype_extend |
Left Kan extension (ΣF) for W-type instances |
wtype_pi |
Right Kan extension (ΠF) for injective migrations |
functor_restrict / functor_extend |
Precomposition and left Kan extension for functor instances |
functor_pi |
Right Kan extension for functor instances |
graph_restrict |
Restrict pipeline for graph-shaped instances |
CompiledMigration |
Pre-computed migration data for fast per-record application |
InstError / ParseError / RestrictError |
Error types |
Example
use ;
let instance = parse_json?;
let errors = validate_wtype;
let round_tripped = to_json;