vnetod/src/domain.rs

27 lines
626 B
Rust

pub mod switch;
#[derive(Debug, Clone, Eq)]
struct Section {
namespace: Option<String>,
name: String,
}
impl<'a> From<&'a str> for Section {
fn from(s: &'a str) -> Self {
let (ns, name) = s
.trim()
.split_once(':')
.map_or_else(|| (None, s), |(ns, name)| (Some(ns), name));
Self {
namespace: ns.map(String::from),
name: String::from(name),
}
}
}
impl PartialEq for Section {
fn eq(&self, other: &Self) -> bool {
self.name == other.name && (self.namespace.is_none() || self.namespace == other.namespace)
}
}