Available on (crate features
deploy or sim) and (crate features maelstrom_runtime or maelstrom) only.Expand description
Runtime support for Maelstrom deployment backend.
This module provides the runtime code that runs inside Maelstrom nodes, handling stdin/stdout JSON message passing according to the Maelstrom protocol.
Structs§
- Init
Body - Maelstrom init message body.
- Init
OkBody - Maelstrom
init_okresponse body. - Maelstrom
Message - Maelstrom message envelope structure.
- Maelstrom
Meta - Metadata for a Maelstrom node, populated from the init message. Also manages a shared stdin reader that broadcasts lines to multiple subscribers.
Functions§
- maelstrom_
client_ source - Creates a stream of client messages from Maelstrom stdin.
Returns tuples of
(client_id, message_body)whereclient_idis the source client andmessage_bodyis the JSON value of the message body. - maelstrom_
init - Initialize a Maelstrom node by reading the init message from stdin.
Returns the node metadata and sends
init_okresponse. Also spawns a background thread to read stdin and broadcast lines to subscribers. - maelstrom_
send_ response - Sends a response to a Maelstrom client via stdout.