/// ```bash /// $ cargo build --examples /// $ maelstrom test -w echo --bin ./target/debug/examples/echo --node-count 1 --time-limit 10 --log-stderr /// ```` use async_trait::async_trait; use maelstrom::protocol::Message; use maelstrom::{done, Node, Result, Runtime}; use std::sync::Arc; pub(crate) fn main() -> Result<()> { Runtime::init(try_main()) } async fn try_main() -> Result<()> { let handler = Arc::new(Handler::default()); Runtime::new().with_handler(handler).run().await } #[derive(Clone, Default)] struct Handler {} #[async_trait] impl Node for Handler { async fn process(&self, runtime: Runtime, req: Message) -> Result<()> { if req.get_type() == "echo" { let echo = req.body.clone().with_type("echo_ok"); return runtime.reply(req, echo).await; } done(runtime, req) } }