pub struct Config { /* private fields */ }Expand description
An IDL-to-Rust compilation, configured the way zerodds-idlc’s own
flags configure it.
Implementations§
Source§impl Config
impl Config
Sourcepub fn include_dir(&mut self, dir: impl Into<PathBuf>) -> &mut Self
pub fn include_dir(&mut self, dir: impl Into<PathBuf>) -> &mut Self
Add a directory to the #include search list — the CLI’s -I.
Sourcepub fn define(
&mut self,
name: impl AsRef<str>,
value: Option<&str>,
) -> &mut Self
pub fn define( &mut self, name: impl AsRef<str>, value: Option<&str>, ) -> &mut Self
Define a macro — the CLI’s -D. None is -DNAME.
Sourcepub fn out_dir(&mut self, dir: impl Into<PathBuf>) -> &mut Self
pub fn out_dir(&mut self, dir: impl Into<PathBuf>) -> &mut Self
Where the generated modules go. Defaults to OUT_DIR.
Sourcepub fn default_extensibility(&mut self, ext: DefaultExt) -> &mut Self
pub fn default_extensibility(&mut self, ext: DefaultExt) -> &mut Self
What an aggregate of unspecified extensibility is taken to be.
Sourcepub fn dialect(&mut self, dialect: Dialect) -> &mut Self
pub fn dialect(&mut self, dialect: Dialect) -> &mut Self
Reproduce one peer’s answers to every wire axis at once — the
same preset zerodds-idlc generate --dialect takes, over the
same Dialect zerodds_ast_layout defines.
The default, Dialect::default (specification), is what
every axis-affecting field already defaulted to before this
existed — a generated module built with no dialect call reads
and writes exactly what it did before. What changes when this is
called is both halves the dialect settles: the front end’s three
lowering options (@hashid’s counter, an escaped name’s
spelling, a declaration named after its own scope), which used
to be the specification’s unconditionally, and the LayoutKey
Self::compile plans the codec under. Self::axis overrides
one answer of whichever dialect is in effect.
Sourcepub fn axis(&mut self, axis: AxisFlag, value: impl Into<String>) -> &mut Self
pub fn axis(&mut self, axis: AxisFlag, value: impl Into<String>) -> &mut Self
Override one wire axis’s answer, after the dialect’s.
axis is one of zerodds_ast_layout::AXES — the same table
zerodds-idlc generate’s --<axis> flags and
wireprobe-zerodds’s read — and value is one of the spellings
AxisFlag::help_values lists for it. Several calls apply in
the order given, each overriding one answer of the dialect
Self::dialect named (or the default dialect, if it was not
called).
Infallible, and applied lazily: a value the axis does not
recognise is refused by Self::compile and
Self::compile_bundle, as Error::Axis, because there is no
command line to refuse it at here — a build.rs that supplied a
typo learns about it the way it learns about a .idl that does
not parse, from the build failing with a message that names it.
AxisFlag::DefaultExtensibility also sets what
Self::default_extensibility sets, because that one axis is
two settings and not one: LayoutKey::default_extensibility,
which Self::layout_key answers for, decides the framing of a
member whose own type has no resolved facet, but a top-level
type’s own facet is resolved once, during composition
(ComposeOptions::default_extensibility), before any
LayoutKey exists — and zerodds_ast::Ast::effective_extensibility,
which the generated DdsType::EXTENSIBILITY and the evolution-
tolerant decode pattern both read, only ever sees the composed
answer. An axis call that touched the LayoutKey alone would
leave those two reading different extensibilities for the same
type — a member framed as @final decoded as if it were
@appendable, silently, because nothing before this call site
caught it. wireprobe-zerodds and zerodds-idlc generate’s own
--default-extensibility do not have this split: the first
never resolves a facet at compose time at all, so its LayoutKey
fallback is the only answer to agree with; the second’s
--default-extensibility is composition’s own flag and was
never routed through the axis table.
Sourcepub fn pl_cdr1_reading(&mut self, reading: PlCdr1Reading) -> &mut Self
pub fn pl_cdr1_reading(&mut self, reading: PlCdr1Reading) -> &mut Self
Whether the generated PL_CDR1 reader takes a stream another implementation framed, or reports it.
PlCdr1Reading::Strict is the default. Under
PlCdr1Reading::Tolerant the reader accepts any flags on
PID_EXTENDED and PID_LIST_END (XTypes 1.3 §7.4.1.2.1), the short
and the extended header of a parameter (§7.4.1.2.2) and a declared
length that is the value’s own or that length rounded up to four
(§7.4.1.2). It changes the generated Rust reader only; the writer
and the generators for other languages are not affected, and there
is no --<axis> flag for it.
Sourcepub fn header_comment(&mut self, comment: impl Into<String>) -> &mut Self
pub fn header_comment(&mut self, comment: impl Into<String>) -> &mut Self
A comment placed at the top of each generated module.
Sourcepub fn typeobject(&mut self, enabled: bool) -> &mut Self
pub fn typeobject(&mut self, enabled: bool) -> &mut Self
Whether to emit the type_objects module.
On by default. It holds one XCDR2-LE serialised minimal
TypeObject per named type, which is what a participant hands to
a peer that asks over the TypeLookup service — a type with no
object cannot be resolved remotely, and the peer finds that out
at discovery time rather than here.
Sourcepub fn type_identifier_constants(&mut self, enabled: bool) -> &mut Self
pub fn type_identifier_constants(&mut self, enabled: bool) -> &mut Self
Whether to emit the type_identifiers module.
Off by default, because the module’s constants are spelled in
zerodds_types terms and pull that crate into the consumer’s
dependencies. A crate that implements zerodds_dcps::DdsType by
hand over the generated codec turns this on to get
TYPE_IDENTIFIER from the same computation discovery uses,
instead of pinning a hash nothing re-checks.
Sourcepub fn dds_type_impls(&mut self, enabled: bool) -> &mut Self
pub fn dds_type_impls(&mut self, enabled: bool) -> &mut Self
Whether to emit impl zerodds_dcps::DdsType for each generated
type.
With this on, a generated type is a topic type:
participant.create_topic::<Robot>("entity.robot") takes it, and
the four codec pairs, the KeyHash holder, the TypeIdentifier
and the TypeObject all come from the model rather than from a
bridge somebody wrote by hand beside the generated file.
Off by default, for the reason
Self::type_identifier_constants is off: the impl is spelled
in zerodds_dcps, zerodds_types and zerodds_wire terms and
puts all three into the consumer’s dependencies. That is the
whole DCPS runtime, and this crate is also used by consumers that
want the codec and nothing else — crates/wire-conformance
compiles the generated modules with no DDS in the graph at all,
and would stop compiling the day a default turned this on. A
default that breaks a build nobody changed is worse than a line
in a build.rs.
Turning it on implies nothing else: the identifier and the object
are written into the impl, not read out of the
Self::type_identifier_constants or Self::typeobject
modules, whose constants are keyed by a type’s simple name
and would collide between two modules declaring one name.
Sourcepub fn emit_cargo_directives(&mut self, enabled: bool) -> &mut Self
pub fn emit_cargo_directives(&mut self, enabled: bool) -> &mut Self
Whether to print cargo:rerun-if-changed lines.
On by default and worth leaving on: cargo does not re-run a build
script for a path it was not told about, so turning this off means
an edit to an .idl produces no rebuild and no message.
Sourcepub fn rust_map(&mut self, form: RustMapForm) -> &mut Self
pub fn rust_map(&mut self, form: RustMapForm) -> &mut Self
How the generated Rust holds an IDL map, as zerodds-idlc --rust-map selects it.
RustMapForm::Entries is the default: Vec<zerodds_wire::MapEntry<K, V>>,
the sequence of MapEntry that XTypes 1.3 §7.5.1.3.6 binds a map to
where a language has no mapping of its own. RustMapForm::BTreeMap
is the option: a BTreeMap<K, V>, whose entries are in ascending key
order and not in the order they were put in.
Sourcepub fn compile_bundle(
&self,
idls: &[impl AsRef<Path>],
name: &str,
) -> Result<(), Error>
pub fn compile_bundle( &self, idls: &[impl AsRef<Path>], name: &str, ) -> Result<(), Error>
Compile several units into one Rust module.
The units are lowered into a shared model, so a module two of
them declare is one node and the generator emits one pub mod
for it. compile gives each unit its own .rs, and two of those
pulled into one Rust scope with include! both open pub mod common — error[E0428]: the name common is defined multiple times, which is issue #39.
That is a structural answer and not a textual one. Concatenating
the units, or writing a synthetic file full of #include lines,
reaches the same output for IDL and buys nothing anywhere else:
the model is shared with DDS-XML, ROS and a TypeObject off the
wire, and node identity is what merges those. zerodds-idl-compose
holds the merge; this only names the output.
name is the output’s stem — world writes world.rs.
§Errors
As Self::compile.