Expand description
Reaching an environment by starting a program.
The simplest way to let another language prove something: run it, hand it one JSON message, and read one back. No linking, no bindings, no foreign function interface — a program that can read standard input and write standard output can participate, which is every language worth naming.
§The exchange
One request in, one response out, and the process exits:
→ {"unitype":"1","kind":"invoke","signature":"demo::sort",
"entry":"bubble_sort","args":[[3,1,2]]}
← {"ok":true,"value":[1,2,3]}Each message is one line, and end of input ends the stream, so a child that reads lines and a child that reads to the end are both correct here. Nothing has to agree on a length prefix, and a child written in ten lines of Python works by construction.
Starting a process per call is real overhead — around twenty milliseconds
for Python, against microseconds of work — which is why the default policy
prefers to stay in this one. A program calling repeatedly should ask for a
worker instead; see crate::worker. This is the version that cannot get
stuck holding state it should not have, which is why it stays the default.
Structs§
- Request
- What the parent sends.
- Response
- What the child sends back.
- Response
Error - A failure the child reported for itself.
Constants§
- PROTOCOL_
VERSION - The wire protocol version this build speaks.
Functions§
- invoke
- Runs an implementation by starting a program and exchanging one message.