Skip to main content

hdds_gen Code Generator

hdds_gen (CLI: hddsgen) is a high-performance IDL 4.2 code generator that produces type support code for multiple languages from a single IDL source.

Features

  • Full IDL 4.2 compliance - 100% support for basic types, templates, constructs
  • 7 target languages - Rust, C++, C, Python, TypeScript, Micro (embedded Rust), C-Micro
  • Zero dependencies - Generated code is self-contained
  • CDR2 serialization - Automatic encode/decode implementation
  • XTypes support - Type evolution and compatibility
  • CI/CD ready - JSON diagnostics, deterministic output

Quick Start

# Install
cargo install hdds-gen

# Generate Rust code
hddsgen gen rust MyTypes.idl -o my_types.rs

# Generate C++ with namespace
hddsgen gen cpp MyTypes.idl --namespace-cpp "MyApp::Types" -o my_types.hpp

# Generate TypeScript
hddsgen gen typescript MyTypes.idl -o my_types.ts

# Generate full example project
hddsgen gen rust MyTypes.idl --example --out-dir ./my_project

Subcommands

CommandPurpose
genGenerate code in target language
parseValidate IDL and pretty-print AST
checkValidate with structural checks (CI-friendly)
fmtReformat IDL to canonical style

Target Languages

LanguageOutputUse Case
rustIdiomatic Rust with derivesNative Rust DDS applications
cppModern C++ headers (.hpp)C++ DDS applications
cHeader-only C99Embedded systems, FFI
pythonDataclasses with type hintsScripting, prototyping
typescriptInterfaces + CDR2 encode/decodeWeb apps, Node.js, Deno
microno_std RustEmbedded Rust (ESP32, ARM)
c-microHeader-only MCU CSTM32, AVR, PIC, ESP32

Feature Support Matrix

Not all backends support all IDL features. Here's the honest breakdown:

FeatureRustC++CPythonTSmicroc-micro
Primitives
Struct
@key
@optional⚠️
Nested structs
Enum
Union⚠️
Typedef
Sequence
Array
Map
Bitset⚠️
Bitmask⚠️
Modules
Inheritance⚠️
@extensibility⚠️

Legend: ✅ Full support (def + codec) | ⚠️ Partial | ❌ Not supported

Coverage Score

BackendScoreNotes
Rust100%Full IDL 4.2 compliance
C++100%Full IDL 4.2 compliance
TypeScript97%Inheritance codec partial
Python94%Bitset/Bitmask codec partial
C88%Legacy C89 constraints
micro63%Embedded constraints (no_std)
c-micro63%Embedded constraints (MCU)

Known Gaps by Design

BackendMissing FeaturesReason
C@optional, Union decode, @extensibilityLegacy C89 compatibility
micro/c-microMap, Bitset, Bitmask, Typedef, @optionalno_std/embedded constraints
PythonBitset/Bitmask codecPlanned improvement
TypeScriptInheritance codecInterface extends OK, codec to verify

Example

Input: Temperature.idl

module sensors {
@topic
struct Temperature {
@key string sensor_id;
float value;
unsigned long long timestamp;
};
};

Output: Rust

#[derive(Debug, Clone, Serialize, Deserialize, Topic)]
pub struct Temperature {
#[key]
pub sensor_id: String,
pub value: f32,
pub timestamp: u64,
}

Output: C

typedef struct {
char* sensor_id;
float value;
uint64_t timestamp;
} sensors_Temperature;

int32_t sensors_Temperature_encode(const sensors_Temperature* p, uint8_t* buf, uint32_t len);
int32_t sensors_Temperature_decode(sensors_Temperature* p, const uint8_t* buf, uint32_t len);

Next Steps