InterfaceOption

Enum InterfaceOption 

Source
pub enum InterfaceOption {
Show 28 variants Address(String), Netmask(String), Gateway(String), Broadcast(String), Network(String), Mtu(u16), BridgeAccess(u16), BridgePorts(Vec<String>), BridgePvid(u16), BridgeVids(String), BridgeVlanAware(bool), MstpctlBpduguard(bool), MstpctlPortadminedge(bool), PostUp(String), PreDown(String), PostDown(String), PreUp(String), Vrf(String), VrfTable(String), VlanId(u16), VlanRawDevice(String), HwAddress(String), DnsNameservers(String), DnsSearch(String), Metric(u32), Pointopoint(String), Media(String), Other(String, String),
}
Expand description

Represents a network interface configuration option with proper typing.

This enum provides strongly typed variants for common interface options, ensuring type safety and validation at compile time where possible.

Unknown options are captured in the InterfaceOption::Other variant.

Variants§

§

Address(String)

IP address, optionally with CIDR notation (e.g., “192.168.1.100” or “192.168.1.100/24”)

§

Netmask(String)

Network mask (e.g., “255.255.255.0”)

§

Gateway(String)

Default gateway address

§

Broadcast(String)

Broadcast address

§

Network(String)

Network address

§

Mtu(u16)

Maximum Transmission Unit

§

BridgeAccess(u16)

VLAN ID for bridge access port

§

BridgePorts(Vec<String>)

List of bridge member ports

§

BridgePvid(u16)

Bridge Port VLAN ID (PVID)

§

BridgeVids(String)

Bridge VLAN IDs (can be ranges like “100-154 199”)

§

BridgeVlanAware(bool)

Whether the bridge is VLAN-aware

§

MstpctlBpduguard(bool)

MSTP BPDU guard setting

§

MstpctlPortadminedge(bool)

MSTP port admin edge setting

§

PostUp(String)

Script to run after interface comes up

§

PreDown(String)

Script to run before interface goes down

§

PostDown(String)

Script to run after interface goes down

§

PreUp(String)

Script to run before interface comes up

§

Vrf(String)

VRF name

§

VrfTable(String)

VRF table (can be “auto” or a number)

§

VlanId(u16)

VLAN ID

§

VlanRawDevice(String)

Raw device for VLAN

§

HwAddress(String)

Hardware address (MAC)

§

DnsNameservers(String)

DNS nameservers

§

DnsSearch(String)

DNS search domains

§

Metric(u32)

Metric for the route

§

Pointopoint(String)

Point-to-point address

§

Media(String)

Media type

§

Other(String, String)

Any other option not explicitly defined

Implementations§

Source§

impl InterfaceOption

Source

pub fn name(&self) -> &str

Returns the option name as it appears in the interfaces file.

Source

pub fn value(&self) -> String

Returns the option value as a string.

Source

pub fn from_key_value(key: &str, value: &str) -> Self

Creates an InterfaceOption from a key-value pair.

This parses the value into the appropriate type based on the key.

Source

pub fn to_key_value(&self) -> (String, String)

Converts the option back to a key-value tuple.

Trait Implementations§

Source§

impl Clone for InterfaceOption

Source§

fn clone(&self) -> InterfaceOption

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InterfaceOption

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for InterfaceOption

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for InterfaceOption

Source§

fn eq(&self, other: &InterfaceOption) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for InterfaceOption

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.