Expand description
An IDL interface, as a complete DDS-RPC 1.0 Rust binding: the
request and reply topic types of §7.5.1.1, a typed client and
service trait, and a dispatcher — all runnable, not only declared.
adapter::interface reads the interface; emit::interface_cpp and
emit::interface_java write declarations a peer’s own runtime gives
a body to. This writes both halves: the topic types get a real
XCDR2 codec, hand-assembled with the same per-field writers
crate::encode::rust_codec uses for an ordinary struct, and the
client and the dispatcher are built over zerodds_rpc::requester
and zerodds_rpc::replier — the crate this generated file has to
depend on, named in the preamble every generated interface carries.
§Why the topic types get a codec here and nowhere else
C++, Java and TypeScript declare Calculator_add_In and stop: the
octets are a job for a type-support pass none of the three has
written (emit::interface_cpp’s own module doc says so). Rust’s
generated client and service actually run — crates/rpc/tests/
sends a request and reads a reply — and a Requester<TIn, TOut>
needs TIn: DdsType. So this crosses the boundary zerodds-rpc → zerodds-dcps → zerodds-lang-rules warns about, deliberately: not by
making this crate depend on zerodds-rpc — it still does not —
but by writing Rust source that does, exactly as
crates/zerodds-build/src/dds_type.rs writes an impl zerodds_dcps::DdsType for a type this crate declared.
§The wire layout
DDS-RPC 1.0 §7.5.1.1’s Basic Service Mapping: one request topic type
and one reply topic type per interface, each a header plus a
data union over every operation. crates/rpc/src/codegen.rs is
the data model this shape comes from; this crate cannot depend on
it (zerodds-rpc depends on zerodds-dcps depends on this crate),
so the shape is read off adapter::interface::Service directly, the
way emit::interface_cpp already does for C++.
A union becomes a Rust enum, one variant per case plus a default
UnknownOp(u8) — §7.5.1.1.6 rule 3 and §7.5.1.1.7 rule 3 — and its
encode/decode write the long discriminator
interface::operation_hash/interface::exception_hash compute,
then delegate to the case payload’s own codec. Every payload type —
an _In, an _Out, a _Result, a raised exception — gets exactly
that: an inherent encode(&self, w: &mut Writer) and decode(r: &mut Reader), member by member, through crate::encode::write_value_to
and crate::encode::read_for — the same two functions
crate::encode::rust_codec calls for a declared struct.
Every synthesized type is @final: no DHEADER, matching
crates/rpc/src/common_types.rs’s own choice for RequestHeader
and ReplyHeader, and matching the classic-CDR shape DDS-RPC 1.0
predates XTypes 1.3’s extensibility kinds with. The encoding is
fixed to XCDR2 little-endian regardless of the file’s own
--encoding/--endian — rpc_layout_key — because
zerodds_rpc::requester::Requester::send_request_blocking calls
TIn::encode, the DdsType bridge’s un-suffixed method, which is
always that one cell.
§What this does not do
It reads @service(name = "…"), @DDSRequestTopic and
@DDSReplyTopic (annotated_topics_expr) and hands the names to
zerodds_rpc::requester::Requester::with_options as
AnnotatedTopics; crates/rpc/src/topic_naming.rs composes the topic
names of §7.4.1 and §7.4.2 from them.
Modules§
- type_
information - The XTypes description of the topic types of the Enhanced Service Mapping
(DDS-RPC 1.0 §7.5.1.2): the
CompleteTypeObjectof${I}_Requestand${I}_Replyand of every type they name.
Enums§
- Rust
Interface Error - Why an interface did not become a Rust binding.
Functions§
- rpc_
layout_ key - The
LayoutKeyevery synthesized topic type’s codec is built under. See the module doc. - rpc_
layout_ key_ xcdr1 - The
LayoutKeyof the XCDR1 (classic CDR) codec of every synthesized topic type, the second pairCodecVariant::XCDR1writes. DDS-RPC 1.0 §7.5.1.1: the Basic Service Mapping is for DDS 1.3. - rust_
interface_ pairs - The Rust declarations and runnable binding every interface of
astproduces, each paired with the module it belongs in so a caller can fold it into the same treecrate::adapter::cst::nest_by_modulebuilds for everything else. - rust_
interface_ pairs_ with rust_interface_pairsfor the given service mapping.- xcdr1_
capable_ types - The declared types that have an XCDR1 codec pair
(
crate::encode::rust_codec_pairunderrpc_layout_key_xcdr1).crate::generateemits those pairs for a model with interfaces, and the topic types’ XCDR1 codec calls them.