use std::collections::BTreeMap;
use std::net::IpAddr;
use anyhow::Result;
#[derive(Debug, Default, Clone)]
pub struct ObservationSet {
pub hosts: BTreeMap<String, HostObservation>,
pub metadata: BTreeMap<String, String>,
}
impl ObservationSet {
pub fn empty() -> Self {
Self::default()
}
pub fn merge(&mut self, other: Self) {
self.hosts.extend(other.hosts);
self.metadata.extend(other.metadata);
}
}
#[derive(Debug, Default, Clone)]
pub struct HostObservation {
pub addresses: Vec<IpAddr>,
pub interfaces: BTreeMap<String, InterfaceObservation>,
pub attributes: BTreeMap<String, String>,
}
#[derive(Debug, Default, Clone)]
pub struct InterfaceObservation {
pub addresses: Vec<IpAddr>,
pub mac_address: Option<String>,
pub default_route: bool,
}
pub trait ObservationProvider: Send + Sync {
fn id(&self) -> &'static str;
fn observe(&self) -> Result<ObservationSet>;
}