Skip to main content

Module stdio

Module stdio 

Source
Expand description

Framed stdio transport for bytes-only named component contracts.

An executable stays alive for its component’s lifetime. Stdin and stdout carry only frames: a four-byte little-endian unsigned JSON byte length, followed by that JSON. Stderr is inherited for diagnostics. Frames are bounded by MAX_FRAME_SIZE. Calls are serialized across all contracts sharing the executable. A timeout or protocol failure terminates and reaps the child; producer status failures leave the connection usable.

The first request is {"op":"describe"}. Its successful response payload contains JSON matching StdioDescriptor, checked against the verified artifact’s manifest. Subsequent requests use {"op":"call","contract":"name","method":"name","payload":[0,255]}. Every response is {"status":0,"payload":[0,255]}. Status codes use AlefStatus semantics; a nonzero status carries error message bytes. Payloads are JSON byte arrays, not base64.

This transport supports crate::LoadedComponent::invoke_bytes. Arbitrary generated C function tables cannot be represented across a process boundary: typed table access and typed instance creation return an explicit unsupported-transport error.

Structs§

StdioDescriptor
Metadata returned as JSON inside the successful describe response payload.
StdioResponse
A response envelope, using the component ABI’s integer status codes.

Enums§

StdioRequest
A request envelope. A producer must answer exactly once for every request.

Constants§

MAX_FRAME_SIZE
STDIO_PROTOCOL_VERSION

Functions§

read_frame
Read one complete bounded frame. EOF, including between frames, is an error.
write_frame
Write and flush one bounded frame.