Add typed Decodal derive support

This commit is contained in:
2026-06-26 00:39:33 +09:00
parent 87fef44c68
commit b8404df047
21 changed files with 729 additions and 11 deletions
+29
View File
@@ -20,6 +20,35 @@ Embedded hosts should depend on `decodal` and provide imports with a `SourceLoad
decodal = "0.1"
```
## Derive support
For embedded Rust applications, `decodal-derive` can generate a Decodal schema and typed decoder from a Rust struct.
```toml
[dependencies]
decodal = "0.1"
decodal-derive = "0.1"
```
```rust
use decodal::{DecodalDecode, DecodalSchema, Engine};
use decodal_derive::Decodal;
#[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.
Binary file not shown.
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "decodal-wasm",
"type": "module",
"description": "WebAssembly wrapper for evaluating Decodal in browser playgrounds.",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT OR Apache-2.0",
"repository": {
"type": "git",