use maelbreaker::{ network::Network, node::Node, payload, runtime::Runtime, types::{Message, Try}, }; use anyhow::anyhow; payload!( enum Payload { Generate, GenerateOk { id: String }, } ); struct UniqueNode { id: String, net: Network, } impl Node for UniqueNode { fn from_init(net: Network, id: String, _: Vec) -> Self { Self { id, net } } fn handle_message(&mut self, msg: Message) -> Try { let id = format!( "{}-{}", self.id, msg.body.msg_id.ok_or(anyhow!("missing id"))? ); let reply = msg.into_reply(Payload::GenerateOk { id }); self.net.send(reply) } } fn main() -> Try { Runtime::::run() }