Skip to main content

Module codegen

Module codegen 

Source
Expand description

Request/reply codegen data model — Spec §7.5.1.

This stage (C6.1.B) derives from a ServiceDef the wire data models of the request and reply topics. The spec distinguishes two layouts:

  • Basic service (Spec §7.5.1.1): one request topic + one reply topic per service type, both with an untyped discriminated union over all methods. Wire form:

    struct <Service>_Request {
        RequestHeader header;
        union <Service>_Call switch (long _d) {
            case OP_<m1>: <Service>_<m1>_In   m1_args;
            case OP_<m2>: <Service>_<m2>_In   m2_args;
            ...
        };
    };

    <Service>_Reply analogously with <Service>_<m>_Out and ReplyHeader.

  • Enhanced service (Spec §7.5.1.2): per method a dedicated request and reply topic with typed per-method structures. Wire form (per method):

    struct <Service>_<m>_In  { /* in/inout params */ };
    struct <Service>_<m>_Out { /* return + out/inout */ };

We produce data structures here (RequestType, ReplyType) with member lists — no language codegen. The language backends in crates/idl-cpp, idl-csharp and idl-java consume the model and emit bindings.

Oneway methods:

  • In the basic layout, a oneway method appears in the request union, but is not included in the reply union — the reply topic is nonetheless shared.
  • In the enhanced layout, build_enhanced_pair returns for a oneway method Some(RequestType) and None as the reply (see MethodPair).

Structs§

CallUnionCase
Discriminator case of a call union (basic layout).
CallUnionDef
<Service>_Call (request) or <Service>_Result (reply) union.
MethodPair
Pair for an enhanced method. Reply is None for oneway.
ReplyType
Reply wire data model. Analogous to RequestType.
RequestType
Request wire data model.
StructMember
Member of a generated wire structure.

Enums§

MemberType
Type of a struct member. Either a known RPC header type (RequestHeader/ReplyHeader/<Service>_Call) or an IDL type from zerodds_idl::ast::TypeSpec.
ServiceLayout
Layout variant of the service wire model (Spec §7.5.1).

Functions§

build_basic_pair
Returns the data models of the basic-layout topics (<Service>_Request plus <Service>_Reply). An empty ServiceDef returns a pair with empty unions — the caller must decide for itself whether to discard it.
build_enhanced_all
Returns all enhanced-layout pairs of a service.
build_enhanced_pair
Returns the per-method pair (request + optional reply).