Skip to main content

Crate panproto_lens_dsl

Crate panproto_lens_dsl 

Source
Expand description

Declarative lens DSL for panproto.

Provides a human-readable specification format for lenses, protolenses, and related optical constructs. Supports Nickel (.ncl), JSON, and YAML surface syntax. Nickel is the primary authoring format, providing typed contracts for validation, record merge for fragment composition, functions for parameterized templates, and imports for modularity.

§Evaluation pipeline

  1. Surface syntax (Nickel/JSON/YAML) is evaluated to a normalized record
  2. The record is deserialized into a LensDocument
  3. The document is compiled to a ProtolensChain + FieldTransforms

§Example

use panproto_lens_dsl::{load, compile};

let doc = load(std::path::Path::new("my_lens.ncl")).unwrap();
let compiled = compile(&doc, "record:body", &|_| None).unwrap();
// compiled.chain is a ProtolensChain ready for instantiation
// compiled.field_transforms are value-level transforms

Re-exports§

pub use compile::CompiledLens;
pub use document::Constraint;
pub use document::HintSpec;
pub use document::HintStringency;
pub use document::LensDocument;
pub use document::PreferencePredicate;
pub use error::LensDslError;

Modules§

compile
Unified compilation dispatcher.
compose
Lens composition via named references.
document
Serde-compatible types for the lens DSL document format.
error
Error types for the lens DSL.
eval
Evaluation of Nickel, JSON, and YAML sources into LensDocument.
rules
Compilation of pattern-match rewrite rules to lens steps.
steps
Compilation of step pipelines to ProtolensChain and FieldTransforms.

Structs§

LoadDirResult
Result of loading a directory of lens documents.

Functions§

compile
Compile a LensDocument to a CompiledLens.
load
Load a lens document from a file.
load_and_compile
Load a lens file and compile it in one step.
load_dir
Load all lens documents from a directory.