Skip to main content

Crate holocron

Crate holocron 

Source
Expand description

Declarative schema & query compiler — one YAML as the source of truth.

Structs§

Catalog
The symbol table: relations and enum types, each looked up by name. Ordered maps keep iteration (and therefore emitted output) deterministic.
CatalogColumn
A resolved column in the catalog: its name, type, nullability, and the per-column query policy resolved from view select-item flags (or the defaults applied to table columns).
CatalogRelation
A named relation (table or view) and its resolved columns.
CheckedQuery
A query that has passed type-checking against the catalog. The only way to build one is through check_query; an unchecked query is unrepresentable at this type (HOLO-PARSE-DONT-VALIDATE).
Column
One column definition: a type, plus nullability and an optional default.
Compiled
The result of compiling a YAML schema: the validated catalog (the symbol table queries are checked against) and the rendered PostgreSQL DDL.
EnumType
A CREATE TYPE … AS ENUM: a named, fixed set of allowed string values.
FromClause
A view’s from: — the source relation and the alias the rest of the view uses.
Index
A CREATE INDEX: a lookup shortcut; affects performance, never results.
Join
A JOIN … ON: combine rows from another relation by a matching rule.
PrimaryKey
The column(s) that uniquely identify a row.
Query
A query against a relation: a filter expression to apply.
SchemaDocument
A whole parsed schema file: the top-level types/tables/views lists.
SelectColumn
A plain column pulled from a from:/join: alias.
SelectExpression
A raw SQL expression with a declared output name (escape hatch).
Span
A half-open byte range [start, end) into the original YAML source.
Spanned
A value paired with the source span it was parsed from.
Table
A CREATE TABLE: physical storage. Columns are an ordered map so emitted DDL is deterministic (insertion order is preserved).
View
A CREATE VIEW … AS: a saved query exposed like a table. Clause fields after select/from/join are raw SQL, passed through verbatim.

Enums§

CatalogType
A resolved column type. Built from the YAML type string; an unresolved type can never exist here (illegal states unrepresentable).
CompareOp
Column-to-value comparison operators.
Comparison
A single comparison against a column. The shape of the value is fixed by the variant — illegal states (e.g. In with one value) are unrepresentable.
Filter
A filter expression tree: logical AND/OR combinators around comparison leaves.
HolocronError
The crate’s single root error type. Each variant carries the source span of the offending token (zero-default when the span is unknown), so the renderer can underline the right place in the YAML.
JoinKind
Which kind of join. INNER keeps only matches; LEFT keeps all left rows.
RelationKind
Whether a relation is a physical table or a derived view.
SelectItem
One item in a view’s select: list. The variant is chosen during lowering by which keys are present (column vs sql).
SetOp
Set-membership operators.

Functions§

build_catalog
Lower the parsed document into a resolved catalog (tables + enums).
check_query
Validate a query against the catalog: every referenced column must exist on the target relation, be filterable, and use an operator the column’s type supports.
compile
Compile a YAML schema end-to-end: parse → build catalog → resolve views → emit DDL.
emit_schema
Render a schema document as PostgreSQL DDL.
parse_schema
Parse YAML into the schema AST.
resolve_views
Resolve every view in the document into a catalog relation, extending the table-and-enum catalog produced by the previous phase.