Expand description
subc wire contract.
This crate is the single source of truth for the subc <-> module wire,
shared by subc-core and AFT. It defines the envelope (the fixed
17-byte routing header subc splices on), the canonical subc-generated body
schemas such as ErrorBody, and the capability manifest. JSON-RPC request
and response bodies remain module-owned opaque payloads to subc.
§The envelope (locked — see docs/subc-core-architecture.md §4.8)
offset size field type purpose
0 4 len u32 # of BODY bytes after this 17-byte header
4 1 ver u8 envelope version
5 1 type u8 frame kind (see FrameType)
6 1 flags u8 bit0 BINARY · bits1-2 PRIORITY · bit3 LAST · 4-7 reserved
7 2 channel u16 route = (component, session); 0 = subc itself
9 8 corr u64 correlation id; CANCEL carries the target call's corr
17 -> bodyLittle-endian (same-machine, native, no byte-swap on the hot path).
Frozen prefix (the versioning invariant): len (u32 @ 0) and ver
(u8 @ 4) keep fixed meaning + position in every future version. A reader
of any version can therefore always read the first 5 bytes, learn ver,
look up that version’s header length, read the rest, and splice len body
bytes. decode_header enforces this discipline.
Re-exports§
pub use frame::Frame;pub use frame::FrameBuildError;
Modules§
- frame
- The complete wire frame: the decoded envelope header plus its opaque body.
- manifest
- Capability manifest schema for subc modules.
- session
- Session route control wire contract.
Structs§
- Bind
Identity - Per-route bind identity shared by client-facing and module-facing control.
- Envelope
Header - A decoded envelope header. The body is the
lenbytes that follow it. - Error
Body - Canonical JSON body for all subc-generated
ERRORframes. - Flags
- The
flagsbyte (offset 6):bit0 BINARY · bits1-2 PRIORITY · bit3 LAST. - Module
Hello AckBody - subc-to-module
HELLO_ACKbody used during module registration. - Module
Hello Body - Module-to-subc
HELLObody used during module registration.
Enums§
- Decode
Error - Why a header could not be decoded.
- Frame
Type - Frame kind (
typebyte at offset 5). - Priority
- Scheduling priority carried in
flagsbits 1-2. subc schedules on this without parsing the body. - Route
Target - Explicit target for a route open/bind operation.
Constants§
- FROZEN_
PREFIX_ LEN - Bytes of the frozen prefix (
lenu32 +veru8) that are stable across every envelope version. A reader needs only these to learn the version and thus the full header length. - HEADER_
LEN - Fixed header length for
PROTOCOL_VERSION1. - MAX_
FRAME_ BODY_ LEN - Maximum v1 frame body accepted before allocation.
- PROTOCOL_
VERSION - Envelope protocol version this build speaks.
- SUBC_
LAUNCH_ NONCE_ ENV - Env var subc sets, on each spawn of a
reservedmodule only, to a fresh one-time launch nonce. The child echoes it inModuleHelloBody::launch_nonce; subc accepts a reserved module_id’s HELLO only when the nonce matches the one it last injected for that id. Non-reserved modules never receive it. - SUBC_
MODULE_ ID_ ENV - Env var subc sets on each supervised child telling it the module_id it is supervised under, so it can register under that id.
Functions§
- decode_
header - Decode an envelope header from the front of
bytes, following the frozen-prefix discipline: