diff --git a/Cargo.toml b/Cargo.toml index 1345176..a511841 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "nebkor-maelstrom" edition = "2024" -version = "1.1.0" +version = "1.1.1" license-file = "LICENSE.md" readme = "README.md" -description = "An easy-to-use and synchronous client for creating Maelstrom distributed clients." +description = "An easy-to-use and synchronous framework for creating Maelstrom distributed clients." repository = "https://git.kittencollective.com/nebkor/nebkor-maelstrom" keywords = ["maelstrom", "glomers", "gossip", "distributed"] diff --git a/src/lib.rs b/src/lib.rs index aa3c747..8259040 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ use std::{ - collections::{BTreeMap, HashMap}, + collections::HashMap, io::{BufRead, Write}, sync::{ Arc, Mutex, OnceLock, @@ -20,7 +20,6 @@ pub type NodeyNodeFace = Arc>; pub type OnInit = Box; pub type RpcFuture = Receiver; pub type RpcResult = std::result::Result, ErrorCode>; -pub type Topology = BTreeMap>; pub trait Node { fn handle(&mut self, runner: &Runner, msg: Message); @@ -233,35 +232,3 @@ pub fn mk_payload(payload: &[(&str, Value)]) -> Payload { .map(|p| (p.0.to_string(), p.1.clone())) .collect() } - -/// Convenience function for turning a `topology` message into a map of node -> -/// neighbors (String -> Vec). -pub fn parse_toplogy(msg: &Message) -> Option { - if msg.typ() != "topology" { - return None; - } - let topology = msg - .body - .payload - .get("topology") - .unwrap() - .as_object() - .cloned() - .unwrap(); - Some( - topology - .into_iter() - .map(|(node, neighbors)| { - ( - node, - neighbors - .as_array() - .unwrap() - .iter() - .map(|neighbor| neighbor.as_str().unwrap().to_string()) - .collect(), - ) - }) - .collect(), - ) -}