use serde::{Serialize,Deserialize}; use std::net::Ipv4Addr; use std::str::FromStr; #[derive(Debug, Deserialize, Serialize)] pub struct Server { pub name: Option, pub domain: Option, pub ip: String, pub port: u16, pub description: Option, pub key: String, // the secret hush hush uwu pub id: u64, pub nickname: Option } #[derive(Deserialize, Serialize)] pub struct Config { pub username: String, // global username that is only overriden in server context's if nickname is used pub servers: Vec } #[derive(Debug, Deserialize)] pub struct Channel { pub ip: String, pub name: String, } impl Channel { pub fn parts(&self) -> (Ipv4Addr, &str) { // return the ip/name of the channel let addr = Ipv4Addr::from_str(&self.ip).unwrap(); (addr, self.name.as_ref()) } }