Decodal

Decodal is a small deterministic DSL for describing, composing, validating, and materializing structured data.

It is designed around a lightweight Rust library:

  • host-supplied source and structured-value imports through ImportLoader
  • shared host environments for production and semantic editor tooling
  • no filesystem access in the library core
  • concrete and abstract values with constraints and defaults
  • deterministic expression evaluation
  • optional regex support behind a Cargo feature
  • browser playground support through WebAssembly

Library crate

Embedded hosts should depend on decodal and provide imports with an ImportLoader.

[dependencies]
decodal = "0.1"

Derive support

For embedded Rust applications, Decodal can generate a schema and typed decoder from a Rust struct with the derive feature.

[dependencies]
decodal = { version = "0.1", features = ["derive"] }
use decodal::{Decodal, DecodalDecode, DecodalSchema, Engine};

#[derive(Decodal)]
struct Service {
    name: String,
    #[decodal(gt = 443, default = 8443)]
    port: i64,
    #[decodal(rename = "feature.enable", default = true)]
    feature_enabled: bool,
}

The derive implements:

  • DecodalSchema, which produces a host schema for Engine::bind_global
  • DecodalDecode, which converts materialized Data into the Rust struct

CLI

A standalone CLI is kept in this repository as the decodal-cli workspace package. It builds a decodal binary, but it is not the primary crates.io package.

Run a Decodal file from the repository:

cargo run -q -p decodal-cli -- examples/advanced/main.dcdl

Enable optional regex support when needed:

cargo run -q -p decodal-cli --features regex -- examples/regex/main.dcdl

Language server

The decodal-language-service crate provides transport-independent evaluation and completion, while decodal-lsp exposes it through the Language Server Protocol with live semantic diagnostics and document formatting. Its library API accepts the same host environment used for production evaluation, so application-defined globals and structured import routing remain available in the editor.

[dependencies]
decodal = "0.2.0"
decodal-language-service = "0.2.0"
decodal-lsp = "0.2.0"

Run the default filesystem-backed server from the repository:

cargo run -q -p decodal-lsp

Embedded applications can implement decodal_lsp::LspEnvironment for their existing HostEnvironment and construct it from the InitializeParams passed to decodal_lsp::run_stdio.

Web playground

The static documentation site and browser playground live under:

site/decodal-site/

Browser hosts can use decodal-wasm. Its DecodalLanguageService accepts JavaScript-owned globals, loadImport, and completeImport callbacks; filesystem and virtual-project policy remain outside the package.

License

Licensed under either of:

  • Apache License, Version 2.0
  • MIT license

at your option.

S
Description
No description provided
Readme
4.3 MiB
Languages
Rust 71%
JavaScript 19.1%
CSS 4.2%
Astro 3.8%
TypeScript 1.3%
Other 0.6%