Struct NetInterface

Source
pub struct NetInterface<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> NetInterface<'a>

Source

pub fn get_mac(&self) -> String

Returns interface mac address or empty mac on any error

Examples found in repository?
examples/netinfo.rs (line 23)
6fn main() -> Result<()> {
7    let mut args = std::env::args().skip(1);
8
9    let adapter = match args.next() {
10        Some(v) => v.parse::<u32>().context("adapter number")?,
11        None => bail!("adapter number not defined"),
12    };
13
14    let device = match args.next() {
15        Some(v) => v.parse::<u32>().context("device number")?,
16        None => 0,
17    };
18
19    let dev = NetDevice::open(adapter, device)?;
20
21    let interface = dev.add_if(0, libdvb_rs::net::sys::DVB_NET_FEEDTYPE_MPE)?;
22    println!("Interface: {}", &interface);
23    let mac = interface.get_mac();
24    println!("MAC: {}", &mac);
25    dev.remove_if(interface)?;
26
27    Ok(())
28}

Trait Implementations§

Source§

impl<'a> Display for NetInterface<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for NetInterface<'a>

§

impl<'a> RefUnwindSafe for NetInterface<'a>

§

impl<'a> Send for NetInterface<'a>

§

impl<'a> Sync for NetInterface<'a>

§

impl<'a> Unpin for NetInterface<'a>

§

impl<'a> UnwindSafe for NetInterface<'a>

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> 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> 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.