diff --git a/Cargo.lock b/Cargo.lock index 525429a..3e1934f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,6 +27,7 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" name = "decodal" version = "0.1.1" dependencies = [ + "decodal-derive", "regex", ] diff --git a/README.md b/README.md index d2b7429..fc36662 100644 --- a/README.md +++ b/README.md @@ -22,17 +22,15 @@ decodal = "0.1" ## Derive support -For embedded Rust applications, `decodal-derive` can generate a Decodal schema and typed decoder from a Rust struct. +For embedded Rust applications, Decodal can generate a schema and typed decoder from a Rust struct with the `derive` feature. ```toml [dependencies] -decodal = "0.1" -decodal-derive = "0.1" +decodal = { version = "0.1", features = ["derive"] } ``` ```rust -use decodal::{DecodalDecode, DecodalSchema, Engine}; -use decodal_derive::Decodal; +use decodal::{Decodal, DecodalDecode, DecodalSchema, Engine}; #[derive(Decodal)] struct Service { diff --git a/crates/decodal-core/Cargo.toml b/crates/decodal-core/Cargo.toml index d300210..6d09673 100644 --- a/crates/decodal-core/Cargo.toml +++ b/crates/decodal-core/Cargo.toml @@ -13,7 +13,9 @@ categories = ["config", "parser-implementations"] [features] default = ["std"] std = [] +derive = ["dep:decodal-derive"] regex = ["std", "dep:regex"] [dependencies] +decodal-derive = { version = "0.1.1", path = "../decodal-derive", optional = true } regex = { version = "1.10", default-features = false, features = ["std", "unicode-perl"], optional = true } diff --git a/crates/decodal-core/src/lib.rs b/crates/decodal-core/src/lib.rs index f05f5a7..0f7c47d 100644 --- a/crates/decodal-core/src/lib.rs +++ b/crates/decodal-core/src/lib.rs @@ -16,6 +16,8 @@ pub mod typed; pub use ast::{Ast, BinaryOp, CompareOp, Expr, ExprId, Field, Literal, Param}; pub use constraints::normalize_constraints; +#[cfg(feature = "derive")] +pub use decodal_derive::Decodal; pub use diagnostic::{Diagnostic, DiagnosticKind, Result}; pub use embedding::{HostField, HostValue}; pub use eval::{Engine, format_diagnostic_with}; diff --git a/doc/manual/souce/design/embedding-api.md b/doc/manual/souce/design/embedding-api.md index eb1f7f2..285fbf7 100644 --- a/doc/manual/souce/design/embedding-api.md +++ b/doc/manual/souce/design/embedding-api.md @@ -89,15 +89,14 @@ This matches the runtime model used for Decodal source-defined schema objects. ## Typed Rust integration -Hosts can use `decodal-derive` to keep a Rust struct, the Decodal schema, and the decoded result in sync. +Hosts can enable the `derive` feature on `decodal` to keep a Rust struct, the Decodal schema, and the decoded result in sync. The derive implements two traits from the `decodal` crate: - `DecodalSchema`: builds a `HostValue` schema that can be passed to `Engine::bind_global`. - `DecodalDecode`: decodes materialized `Data` back into the Rust type. ```rust -use decodal::{DecodalDecode, DecodalSchema, EmptyLoader, Engine}; -use decodal_derive::Decodal; +use decodal::{Decodal, DecodalDecode, DecodalSchema, EmptyLoader, Engine}; #[derive(Decodal)] struct Service { diff --git a/doc/manual/souce/development.md b/doc/manual/souce/development.md index 667b159..4f2a3cc 100644 --- a/doc/manual/souce/development.md +++ b/doc/manual/souce/development.md @@ -28,8 +28,8 @@ Workspace support crates such as `decodal-cli` and `decodal-wasm` are not publis The project is dual licensed as `MIT OR Apache-2.0`. ```sh -cargo publish -p decodal cargo publish -p decodal-derive +cargo publish -p decodal ``` Before publishing, run: @@ -38,8 +38,8 @@ Before publishing, run: cargo fmt --check cargo test cargo check -p decodal --no-default-features -cargo publish -p decodal --dry-run cargo publish -p decodal-derive --dry-run +cargo publish -p decodal --dry-run ``` ## Web site and playground