Skip to main content

Crate zerodds_build

Crate zerodds_build 

Source
Expand description

Crate zerodds-build. Safety classification: TOOLING.

A build.rs helper for ZeroDDS IDL.

Build-time only ([build-dependencies]), std, forbid(unsafe_code).

fn main() -> Result<(), zerodds_build::Error> {
    zerodds_build::Config::new()
        .include_dir("idl")
        .compile(&["idl/Robot.idl"])
}

Each .idl becomes one .rs in OUT_DIR, named after the file, to be pulled in with include!:

ⓘ
include!(concat!(env!("OUT_DIR"), "/Robot.rs"));

§Topic types

What that writes is the Rust type and its codec — a pair of inherent functions over zerodds_wire. DomainParticipant::create_topic takes a T: zerodds_dcps::DdsType, which is a different surface, and Config::dds_type_impls writes it:

fn main() -> Result<(), zerodds_build::Error> {
    zerodds_build::Config::new()
        .dds_type_impls(true)
        .compile(&["idl/Robot.idl"])
}
ⓘ
participant.create_topic::<Robot>("entity.robot")?;

It is off by default because it puts zerodds-dcps, zerodds-types and zerodds-wire into the consumer’s [dependencies]; the option’s own documentation says why that is not a default worth taking.

§Where it goes

At the crate root. The generated modules name types across module boundaries with paths relative to where they sit, and each pub mod carries use super::* so the file’s own imports reach into it. Both hold wherever the file is included; what does not hold is splitting one .idl’s output across two places.

§Rebuilds

Every .idl passed here and every file it #includes is reported to cargo as rerun-if-changed. Without the second half, an edit to an included file leaves the generated code stale and nothing says so: cargo does not re-run a build script for a path it was not told about.

Structs§

Config
An IDL-to-Rust compilation, configured the way zerodds-idlc’s own flags configure it.

Enums§

DefaultExt
What an aggregate of unspecified extensibility is taken to be.
Error
What went wrong.
RustMapForm
How the generated Rust holds an IDL map (Config::rust_map). How the Rust column holds an IDL map.

Functions§

compile
Compile with the defaults — the one-liner form.