pub struct Connection { /* private fields */ }

Implementations§

source§

impl Connection

source

pub fn connection(&self) -> Result<String, Error>

source

pub fn specific_object(&self) -> Result<String, Error>

source

pub fn id(&self) -> Result<String, Error>

Examples found in repository?
examples/testing.rs (line 17)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() -> Result<(), Error> {
    let nm = NetworkManager::new()?;

    for dev in nm.get_devices()? {
        match dev {
            Device::Ethernet(x) => {
                println!("Is autoconnected: {:?}", x.autoconnect()?);
                println!("Speed: {:?}", x.speed()?);
                println!("S390 Subchannels: {:?}", x.s390_subchannels()?);
                println!("Carrier: {:?}", x.carrier()?);
                let conf = x.ip4_config()?;
                println!("Gateway: {:?}", conf.gateway()?);
                let con = x.active_connection()?;
                println!("Connection id: {}", con.id()?);
            }
            Device::WiFi(x) => {
                println!("Bitrate: {:?}", x.bitrate()?);
                x.request_scan(std::collections::HashMap::new())?;
                for ap in x.get_all_access_points()? {
                    println!("SSID: {:?}", ap.ssid()?);
                }
            }
            _ => {}
        }
    }

    let eth0 = nm.get_device_by_ip_iface("eth0")?;
    match eth0 {
        Device::Ethernet(x) => {
            // NetworkManager >= 1.24
            // println!("Hardware Address: {:?}", Any::hw_address(&x)?);

            // NetworkManager < 1.24
            // println!("Hardware Address: {:?}", Wired::hw_address(&x)?);

            println!("Speed: {:?}", x.speed()?);
        }
        _ => {}
    }

    Ok(())
}
source

pub fn uuid(&self) -> Result<String, Error>

source

pub fn type_(&self) -> Result<String, Error>

source

pub fn devices(&self) -> Result<Vec<Device>, Error>

source

pub fn state(&self) -> Result<ActiveConnectionState, Error>

source

pub fn state_flags(&self) -> Result<ActivationStateFlags, Error>

source

pub fn default(&self) -> Result<bool, Error>

source

pub fn ip4_config(&self) -> Result<Ip4Config, Error>

source

pub fn dhcp4_config(&self) -> Result<Dhcp4Config, Error>

source

pub fn default6(&self) -> Result<bool, Error>

source

pub fn ip6_config(&self) -> Result<Ip6Config, Error>

source

pub fn dhcp6_config(&self) -> Result<Dhcp6Config, Error>

source

pub fn vpn(&self) -> Result<bool, Error>

source

pub fn master(&self) -> Result<Device, Error>

Trait Implementations§

source§

impl Clone for Connection

source§

fn clone(&self) -> Connection

Returns a copy 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 Connection

source§

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

Formats the value using the given formatter. Read more

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.