Added helper in Channel struct to easily parse out ip/name

This commit is contained in:
shockrah 2021-01-17 21:37:04 -08:00
parent 9b4909963d
commit 20563f85d6

View File

@ -1,6 +1,8 @@
use serde::{Serialize,Deserialize};
use std::net::Ipv4Addr;
use std::str::FromStr;
#[derive(Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
pub struct Server {
pub name: Option<String>,
pub domain: Option<String>,
@ -17,8 +19,17 @@ pub struct Config {
pub servers: Vec<Server>
}
#[derive(Deserialize)]
#[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())
}
}