Module msg

Module msg 

Source
Expand description

Maelstrom network message protocol

A message Maelstrom workload client message can be created as follows

use async_maelstrom::msg::Msg;
use async_maelstrom::msg::Body::Echo;

// Receive an echo request
let request = recv();
if let Msg {
    src: client_id,
    body: Client(Echo {msg_id, echo}),
    ..
} = request {
    // Create an echo response
    let node_id = "n1".to_string();
    let response: Msg<()> = Msg {
        src: node_id,
        dest: client_id,
        body: Echo(EchoOk {
            in_reply_to: msg_id,
            msg_id: Some(5),
            echo,
    })};
    send(response);
}

Structs§

Error
Maelstrom errors
Msg
Maelstrom network message

Enums§

Body
Echo
Maelstrom client message body
Init
Maelstrom node initialization
LinKv
Maelstrom Lin-kv workload messages
PnCounter
Maelstrom Lin-kv workload messages

Type Aliases§

Key
Maelstrom Lin-kv workload key
MsgId
Maelstrom message ID
Val
Maelstrom Lin-kv workload value