Skip to main content

Module convert

Module convert 

Source
Expand description

Conversion from EureDocument to SchemaDocument

This module provides functionality to convert Eure documents containing schema definitions into SchemaDocument structures.

§Schema Syntax

Schema types are defined using the following syntax:

Primitives (shorthands via inline code):

  • `text`, `integer`, `float`, `boolean`, `null`, `any`
  • `text.rust`, `text.email`, `text.plaintext`

Primitives with constraints:

@ field {
  $variant = "text"
  min-length = 3
  max-length = 20
  pattern = `^[a-z]+$`
}

Array: [`text`] or { $variant = "array", item = `text`, ... }

Tuple: (`text`, `integer`) or { $variant = "tuple", elements = [...] }

Record: { name = `text`, age = `integer` }

Union with named variants:

@ field {
  $variant = "union"
  variants.success = { data = `any` }
  variants.error = { message = `text` }
  variants.error.$ext-type.unambiguous = true  // optional, for catch-all variants
  $interop.variant-repr = "untagged"  // optional
}

Literal: Any constant value (e.g., { = "active", $variant = "literal" }, 42, true)

Type reference: `$types.my-type` or `$types.namespace.type`

Structs§

SchemaSource
Source document location for a schema node.

Enums§

ConversionError
Errors that can occur during document to schema conversion

Functions§

document_to_schema
Backwards-compatible single-document entry point. $import entries require a pre-loaded graph.
document_to_schema_with_layout
Backwards-compatible single-document entry point. $import entries require a pre-loaded graph, so use loaded_schema_set_to_schema_with_layout for import support.
loaded_schema_set_to_schema
Convert a pre-loaded schema import graph to a schema.
loaded_schema_set_to_schema_with_layout
Convert a pre-loaded schema import graph and compute its layout strategies.

Type Aliases§

SchemaSourceMap
Mapping from schema node IDs to their source document node IDs. Used for propagating origin information for error formatting.