extern crate conshash;
use std::collections::hash_map::DefaultHasher;
#[derive(Clone, Debug)]
struct TestNode {
host_name: &'static str,
ip_address: &'static str,
port: u32,
}
impl ToString for TestNode {
fn to_string(&self) -> String {
format!("{}{}", self.ip_address.to_string(), self.port.to_string())
}
}
let mut hash_ring = conshash::Ring::new(5);
let test_node = TestNode{host_name: "Skynet", ip_address: "192.168.1.1", port: 42};
hash_ring.add_node(&test_node);
hash_ring.remove_node(&test_node);
hash_ring.add_node(&test_node);
let x = hash_ring.get_node(conshash::hash(&format!("{}{}", test_node.to_string(), 0.to_string())));