zerodds-idl-rust
IDL4 → Rust code generator for ZeroDDS DataTypes.
Reads the IDL AST from zerodds-idl and emits Rust code with:
pub struct/pub enum/pub typeimpl zerodds_dcps::DdsType(encode/decode/encode_key_holder_be)impl zerodds_cdr::CdrEncode/CdrDecodefor enums
Complements the other language codegens idl-cpp / idl-csharp / idl-java / idl-ts with the Rust path — end users can use IDL-first workflows in Rust too.
Layer position
Layer 3 (schema). Build-time tool, std-only, forbid(unsafe_code).
What is emitted
| IDL | Rust |
|---|---|
struct (final) |
pub struct + impl DdsType with XCDR2 final wire |
struct (@appendable) |
with zerodds_cdr::struct_enc::encode_appendable |
struct (@mutable) |
with zerodds_cdr::struct_enc::MutableStructEncoder |
enum |
pub enum #[repr(i32)] + from_wire + CdrEncode/Decode |
union |
pub enum with variants per case |
typedef |
pub type X = Y; |
module |
pub mod m { ... } with nested definitions |
@key |
encode_key_holder_be implementation, member-id-sorted |
@id(N) |
member ID for mutable extensibility and KeyHolder sorting |
Quickstart
use ParserConfig;
use ;
let ast = parse.expect;
let rust_src = generate_rust_module.expect;
println!;
Tests
- Snapshot tests (
tests/snapshot_codegen.rs) — 13 tests, each compares the emitted code against a committed.snapfile. - Compile-check tests (
tests/compile_check.rs,--include-ignored) — 8 tests, each actually compiles the emitted code against a temp crate with path deps onzerodds-cdr+zerodds-dcps. Proves the output is not only snapshot-consistent but also really compilable.
License
Apache-2.0. See LICENSE.
See also
docs/architecture/02_architecture.md— layer architecturecrates/idl-cpp— reference codegen (C++17 header)crates/idl-csharp— C# P/Invoke codegencrates/idl-java— Java JNI codegencrates/idl-ts— TypeScript codegen