Added helper in Channel struct to easily parse out ip/name
This commit is contained in:
parent
9b4909963d
commit
20563f85d6
@ -1,6 +1,8 @@
|
|||||||
use serde::{Serialize,Deserialize};
|
use serde::{Serialize,Deserialize};
|
||||||
|
use std::net::Ipv4Addr;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Server {
|
pub struct Server {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub domain: Option<String>,
|
pub domain: Option<String>,
|
||||||
@ -17,8 +19,17 @@ pub struct Config {
|
|||||||
pub servers: Vec<Server>
|
pub servers: Vec<Server>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Channel {
|
pub struct Channel {
|
||||||
pub ip: String,
|
pub ip: String,
|
||||||
pub name: 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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user