use net_lattice_core::Result;
use crate::InterfaceProvider;
pub trait InterfaceMutator: InterfaceProvider {
type InterfaceConfig;
fn set_interface_config(&self, config: Self::InterfaceConfig) -> Result<Self::Interface>;
}
#[cfg(test)]
mod tests {
use super::InterfaceMutator;
use crate::InterfaceProvider;
use net_lattice_core::Result;
struct Backend;
impl InterfaceProvider for Backend {
type Interface = u32;
fn interfaces(&self) -> Result<Vec<Self::Interface>> {
Ok(Vec::new())
}
}
impl InterfaceMutator for Backend {
type InterfaceConfig = u32;
fn set_interface_config(&self, config: Self::InterfaceConfig) -> Result<Self::Interface> {
Ok(config)
}
}
#[test]
fn interface_mutator_returns_the_observed_associated_type() {
assert_eq!(Backend.set_interface_config(7).expect("configured"), 7);
}
}