21 lines
458 B
Rust
21 lines
458 B
Rust
use nebkor_maelstrom::{Body, Message, Node, Runner};
|
|
|
|
struct Echo;
|
|
|
|
impl Node for Echo {
|
|
fn handle(&mut self, runner: &Runner, msg: Message) {
|
|
let typ = &msg.body.typ;
|
|
if typ.as_str() == "echo" {
|
|
let body = Body::from_type("echo_ok").with_payload(msg.body.payload.clone());
|
|
runner.reply(&msg, body);
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let node = Echo;
|
|
|
|
let runner = Runner::new(node);
|
|
|
|
runner.run(None);
|
|
}
|