Crates.io | dust_dds_gen |
lib.rs | dust_dds_gen |
version | 0.13.0 |
created_at | 2023-04-06 12:18:23.210729+00 |
updated_at | 2025-09-15 19:10:50.021404+00 |
description | OMG IDL compiler for Dust DDS |
homepage | https://s2e-systems.com/products/dust-dds |
repository | https://github.com/s2e-systems/dust-dds |
max_upload_size | |
id | 832143 |
size | 100,437 |
A tool that generates Rust code for Dust DDS from IDL files. If using only Rust, you can make use of the procedural macros to enable a type to be transmitted using Dust DDS. This crate is useful in all cases where you want to use different programming languages or vendors or want to have the types defined externally to the code in idl format.
Some of the relevant features of Dust DDS IDLgen:
@key
definition on the struct fields#define
, #include
, #ifdef
and #ifndef
This IDL gen is shipped as a library instead of a self standing tool since its main use case is to be integrated with a build.rs
script. The entry function is dust_dds_gen::compile_idl(&idl_path)
which generates a string with the output Rust code. Here is an example of a 'build.rs' file using the IDL generator:
fn main() {
let cargo_target_dir = std::env::var("OUT_DIR").unwrap();
let cargo_manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let cargo_target_path = Path::new(&cargo_target_dir);
let cargo_manifest_path = Path::new(&cargo_manifest_dir);
let build_path = cargo_target_path.join("idl");
let idl_path = cargo_manifest_path.join("res/ShapeType.idl");
let compiled_idl = dust_dds_gen::compile_idl(&idl_path).expect("Couldn't parse IDL file");
let compiled_idl_path = build_path.as_path().join("shapes_type.rs");
fs::create_dir_all(build_path).expect("Creating build path failed");
let mut file = File::create(compiled_idl_path).expect("Failed to create file");
file.write_all(compiled_idl.as_bytes()).expect("Failed to write to file");
}
Once the file is generated it can be included in the code by using the include!
macro:
include!(concat!(env!("OUT_DIR"), "/idl/shapes_type.rs"));
This project is licensed under the Apache License Version 2.0.