pub struct NetworkInterfaces { /* private fields */ }
Expand description
Represents the collection of network interfaces defined in an interfaces(5)
file.
The NetworkInterfaces
struct provides methods to load, manipulate, and save
network interface configurations.
§Examples
Loading and modifying interfaces:
use interface_rs::NetworkInterfaces;
use interface_rs::interface::Interface;
let mut net_ifaces = NetworkInterfaces::load("tests/interfaces").unwrap();
// Modify an interface
if let Some(iface) = net_ifaces.get_interface_mut("eth0") {
iface.method = Some("static".to_string());
iface.options.push(("address".to_string(), "192.168.1.100".to_string()));
}
// Save changes
net_ifaces.save().unwrap();
Implementations§
Source§impl NetworkInterfaces
impl NetworkInterfaces
Sourcepub fn get_interface(&self, name: &str) -> Option<&Interface>
pub fn get_interface(&self, name: &str) -> Option<&Interface>
Sourcepub fn get_interface_mut(&mut self, name: &str) -> Option<&mut Interface>
pub fn get_interface_mut(&mut self, name: &str) -> Option<&mut Interface>
Sourcepub fn add_interface(&mut self, iface: Interface)
pub fn add_interface(&mut self, iface: Interface)
Sourcepub fn delete_interface(&mut self, name: &str)
pub fn delete_interface(&mut self, name: &str)
Sourcepub fn get_existing_vni_vlan(&self, vni_id: u32) -> Option<u16>
pub fn get_existing_vni_vlan(&self, vni_id: u32) -> Option<u16>
Sourcepub fn get_bridge_interfaces(&self) -> Vec<String>
pub fn get_bridge_interfaces(&self) -> Vec<String>
Retrieves all port names that have a bridge-access
option defined.
§Returns
A Vec<String>
containing the names of the ports with bridge-access
defined.
Trait Implementations§
Source§impl Debug for NetworkInterfaces
impl Debug for NetworkInterfaces
Auto Trait Implementations§
impl Freeze for NetworkInterfaces
impl RefUnwindSafe for NetworkInterfaces
impl Send for NetworkInterfaces
impl Sync for NetworkInterfaces
impl Unpin for NetworkInterfaces
impl UnwindSafe for NetworkInterfaces
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more