node_info.rs 636 B

123456789101112131415161718192021222324252627282930
  1. //TODO: made node_id into a HashSet(u32)
  2. // wrap NodeInfo and NodeId in a Mutex
  3. pub type NodeId = u32;
  4. #[derive(Clone)]
  5. pub struct NodeInfo {
  6. pub id: String,
  7. pub connections: usize,
  8. pub is_active: bool,
  9. pub last_message: String,
  10. }
  11. impl NodeInfo {
  12. pub fn new() -> NodeInfo {
  13. let connections = 0;
  14. let is_active = false;
  15. NodeInfo { id: String::new(), connections, is_active, last_message: String::new() }
  16. }
  17. }
  18. impl Default for NodeInfo {
  19. fn default() -> Self {
  20. Self::new()
  21. }
  22. }
  23. //pub async fn add_seen(&self, id: u32) {
  24. // self.privmsg_ids.lock().await.insert(id);
  25. //}