pub use net_lattice_core::{Error, Id, PlatformErrorCode, Result};
pub use net_lattice_ip::{
Ipv4Address, Ipv4Network, Ipv4PrefixLength, Ipv6Address, Ipv6Network, Ipv6PrefixLength,
};
pub use net_lattice_model::route::{Route, RouteId};
pub use net_lattice_model::{IpAddress, Network};
pub use net_lattice_platform::{Capability, RouteProvider};
pub trait LatticeBackend: RouteProvider<Route = Route> {}
impl<B> LatticeBackend for B where B: RouteProvider<Route = Route> {}
pub struct Lattice<B: LatticeBackend> {
backend: B,
}
impl<B: LatticeBackend> Lattice<B> {
pub fn routes(&self) -> Result<Vec<Route>> {
self.backend.routes()
}
pub fn add_route(&self, route: Route) -> Result<()> {
self.backend.add_route(route)
}
pub fn remove_route(&self, route: Route) -> Result<()> {
self.backend.remove_route(route)
}
}
#[cfg(target_os = "linux")]
impl Lattice<net_lattice_backend_linux::LinuxBackend> {
pub fn connect() -> Result<Self> {
Ok(Self {
backend: net_lattice_backend_linux::LinuxBackend::new()?,
})
}
}