Add typed Decodal derive support
This commit is contained in:
@@ -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.
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user