Skip to main content

Module builders

Module builders 

Source
Expand description

Generate TypeScript request builder functions.

For each request union variant, generates a function that constructs a Cap’n Proto binary message with correct wire format offsets.

Scoped clients get builder functions that construct the full chain: root → init inner struct → set scope fields → set discriminant → payload.

Functions§

emit_field_setter 🔒
Emit a setter call for a field on a builder variable.
emit_group_arm_setter 🔒
Write an inline union group arm’s leaf fields onto builder_var.
emit_option_setter 🔒
Emit code to write an Option* wrapper struct at a pointer slot.
emit_struct_init 🔒
Emit code to init a sub-struct and set its non-union fields.
emit_union_element_setter 🔒
Emit a switch statement that writes union discriminant + variant payload for a list element.
find_chain_variant_info 🔒
Find the discriminant byte offset, discriminant value, and slot offset for the variant that leads to chain[level] from its parent.
find_inner_struct_name 🔒
Find the inner struct type name for chain[level].
generate_builders
Generate all request builder functions for a service.
generate_plain_struct_builder 🔒
Generate a single builder function for a non-union struct.
generate_scoped_builders 🔒
Generate builder functions for a scoped client’s methods.
generate_struct_builders
Generate standalone builder functions for all structs in a schema.
is_service_struct 🔒
Check if a struct is the service request or response struct (handled by generate_builders).
value_expr_for_field 🔒
Optional fields carry T | undefined; coalesce to the capnp default so TypeScript strict mode doesn’t reject passing T | undefined to a setter.