zerodds-idl-rust 1.0.0-rc.5

IDL4 → Rust code generator for ZeroDDS DataTypes (impl DdsType from zerodds-dcps).
Documentation

zerodds-idl-rust

License: Apache-2.0 docs.rs

IDL4 → Rust code generator for ZeroDDS DataTypes.

Reads the IDL AST from zerodds-idl and emits Rust code with:

  • pub struct / pub enum / pub type
  • impl zerodds_dcps::DdsType (encode/decode/encode_key_holder_be)
  • impl zerodds_cdr::CdrEncode / CdrDecode for 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 zerodds_idl::config::ParserConfig;
use zerodds_idl_rust::{generate_rust_module, RustGenOptions};

let ast = zerodds_idl::parse(
    "@appendable struct Telemetry { unsigned long ts; double v; };",
    &ParserConfig::default(),
).expect("parse");

let rust_src = generate_rust_module(&ast, &RustGenOptions::default()).expect("gen");
println!("{rust_src}");

Tests

  • Snapshot tests (tests/snapshot_codegen.rs) — 13 tests, each compares the emitted code against a committed .snap file.
  • Compile-check tests (tests/compile_check.rs, --include-ignored) — 8 tests, each actually compiles the emitted code against a temp crate with path deps on zerodds-cdr+zerodds-dcps. Proves the output is not only snapshot-consistent but also really compilable.
cargo test -p zerodds-idl-rust --tests                                  # snapshot + smoke
cargo test -p zerodds-idl-rust --test compile_check -- --include-ignored # real-compile

License

Apache-2.0. See LICENSE.

See also