made client_of a default attribute
This commit is contained in:
parent
d021745cde
commit
04937f5a9d
2 changed files with 10 additions and 9 deletions
16
src/main.rs
16
src/main.rs
|
@ -33,6 +33,7 @@ fn main() {
|
|||
pub struct Host {
|
||||
name: String,
|
||||
ip: String,
|
||||
parent: String,
|
||||
kind: HostKind,
|
||||
}
|
||||
impl Host {
|
||||
|
@ -79,19 +80,20 @@ impl Host {
|
|||
}
|
||||
fn to_dot_edge(&self) -> Option<String> {
|
||||
match self.kind {
|
||||
HostKind::Client { ref parent, ref ssid, .. } =>
|
||||
format!("\"{name}\" -- \"{parent}\" [label=\"{ssid}\"]", name=self.name, parent=parent, ssid=ssid).into(),
|
||||
HostKind::AccessPoint { ref parent, .. } =>
|
||||
format!("\"{name}\" -- \"{parent}\"", name=self.name, parent=parent).into(),
|
||||
_ => None,
|
||||
HostKind::Client { ref ssid, .. } =>
|
||||
format!("\"{name}\" -- \"{parent}\" [label=\"{ssid}\"]", name=self.name, parent=self.parent, ssid=ssid).into(),
|
||||
// hier eventuelle ausnahmen für bestimmte typen die keine parents haben eintragen
|
||||
// mainly template und sol
|
||||
_ =>
|
||||
format!("\"{name}\" -- \"{parent}\"", name=self.name, parent=self.parent).into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum HostKind {
|
||||
Client { mac: String, subnet: String, coordinates: Option<[f64;2]>, parent: String, ssid: String },
|
||||
AccessPoint { mac: String, ssid: String, parent: String },
|
||||
Client { mac: String, subnet: String, coordinates: Option<[f64;2]>, ssid: String },
|
||||
AccessPoint { mac: String, ssid: String },
|
||||
Service,
|
||||
Other,
|
||||
}
|
||||
|
|
|
@ -56,16 +56,15 @@ impl RawHost {
|
|||
Host
|
||||
{ name: name.clone()
|
||||
, ip: self.ansible_host
|
||||
, parent: self.client_of.unwrap_or_else(|| missingwarn("client_of"))
|
||||
, kind: match self.kind.as_ref()
|
||||
{ "wlan-ap" => HostKind::AccessPoint
|
||||
{ mac: self.mac.unwrap_or_else(|| missingpanic("mac"))
|
||||
, ssid: self.link_ssid.unwrap_or_else(|| missingwarn("link_ssid"))
|
||||
, parent: self.client_of.unwrap_or_else(|| missingwarn("client_of"))
|
||||
}
|
||||
, "client" => HostKind::Client
|
||||
{ subnet: self.subnet.unwrap_or_else(|| missingpanic("subnet"))
|
||||
, coordinates: self.coordinate
|
||||
, parent: self.client_of.unwrap_or_else(|| missingwarn("client_of"))
|
||||
, mac: self.mac.unwrap_or_else(|| missingpanic("mac"))
|
||||
, ssid: self.link_ssid.unwrap_or_else(|| missingwarn("link_ssid"))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue