Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rust SDK reference

The Rust entry point is the panproto-core facade. Version 0.72 requires Rust 1.85 or later.

[dependencies]
panproto-core = "0.72"

The facade re-exports each component crate as a module. For instance, panproto_core::schema::Schema is the Schema type from panproto-schema. Depending on panproto-schema directly exposes the same type without the facade.

Modules

ModuleRe-exported cratePrincipal surface
checkpanproto-checkStructural diffs, compatibility classification, and validation
gatpanproto-gatTheories, models, theory morphisms, and colimits
schemapanproto-schemaProtocols, schemas, builders, morphisms, and pushouts
instpanproto-instTree, relational, and graph instance representations
migpanproto-migMigration compilation, lifting, composition, and morphism search
lenspanproto-lensLenses, protolenses, complements, and law checks
protocolspanproto-protocolsBuilt-in protocol definitions
iopanproto-ioInstance parsing and emission
vcspanproto-vcsSchema and data version control
expr, expr_parserpanproto-expr, panproto-expr-parserExpression values, evaluation, parsing, and formatting
lens_dsl, theory_dslpanproto-lens-dsl, panproto-theory-dslDeclarative lens and theory front ends

The crate map lists lower-level workspace crates that are not re-exported from panproto-core.

Feature flags

panproto-core has no default features.

FeatureAdditional module or behaviorImplied features
full-parseRe-exports panproto-parse as parsenone
projectRe-exports panproto-project as projectfull-parse
gitRe-exports panproto-git as gitproject, hence full-parse
tree-sitterEnables the panproto-io/tree-sitter implementationnone

full-parse adds the tree-sitter grammar build dependencies described in the crate manifest. It is separate from the tree-sitter feature on panproto-io.

Instance transport and direction

Let a compiled migration have schema direction (F:S\to T). The functorial data-migration names (\Sigma_F) and (\Delta_F) follow the usual source and target directions (Spivak 2012), but the plain lift API is a separate operation:

Rust APIInstance directionImplemented operation
lift_wtype, lift_functor(S\to T)Runs the restrict pipeline. It retains the source fragment that survives the compiled mapping, remaps it into the target schema, and may prune data.
lift_wtype_sigma, lift_functor_sigma(S\to T)Computes the left Kan extension (\Sigma_F). The functor form may then run the supplied chase dependencies.
lift_wtype_pi(S\to T)Runs the pi-named W-type path. It accepts only vertex-injective maps and relabels the tree rather than constructing a general right Kan extension. Its max_product_nodes parameter is retained for signature compatibility and is unused.
lift_functor_pi(S\to T)Computes the functor-instance right Kan extension (\Pi_F) by products over fibers and applies max_product_size.
w_delta, f_delta(T\to S)Computes precomposition (\Delta_F). The W-type form is defined only for injective vertex and edge maps and for anchors in the image. The functor form also handles vertex-merging maps.

Thus panproto_mig::lift_wtype is not (\Delta_F), despite its delegation to wtype_restrict. Instance::restrict has the same source-to-target surviving-fragment direction. Instance::extend is a total source-to-target extension path. The W-type (\Sigma_F) implementation delegates to that path, but the generic method does not establish an adjunction for every Instance variant.

The panproto_core::mig::hom_search module distinguishes partial overlap from total morphisms. A returned SchemaSpan has shape (S\leftarrow A\to T): (A) is the sub-schema of (S) induced by mapped source vertices, the left leg includes (A) into (S), and the right leg maps (A) into (T).

find_span(
    src: &Schema,
    tgt: &Schema,
    protocol: &Protocol,
    opts: &SearchOptions,
) -> Result<SchemaSpan, SpanError>

find_morphisms(
    src: &Schema,
    tgt: &Schema,
    opts: &SearchOptions,
) -> Result<MorphismList, SpanError>

find_best_morphism(
    src: &Schema,
    tgt: &Schema,
    opts: &SearchOptions,
) -> Result<Option<FoundMorphism>, SpanError>

find_span may return an empty apex when the schemas share no vertices. The protocol argument is used to validate the induced apex. Setting SearchOptions::epic is invalid for this partial search and returns SpanError::EpicIsNotASpanProperty.

find_morphisms returns total morphisms that attain the optimum, rather than every morphism or a sequence of lower-quality alternatives. MorphismList::truncated records whether enumeration of tied optima stopped at the engine cap. An empty morphisms vector means that no total morphism exists. A search that could not run returns Err.

SearchOptions::default() leaves monic, epic, and iso false, uses no hard pins, and sets max_results to zero. Here zero requests all optima the implementation will enumerate, subject to its safety cap. Use find_morphisms_budgeted or SpanSearch when the caller must supply a SearchBudget.

Ownership and errors

Rust values follow ordinary ownership and drop semantics. The Rust API does not expose the opaque-handle lifecycle used by foreign-language bindings. Fallible operations return the error type declared by their component crate. panproto-core does not replace those errors with a facade-wide error enum.

See also