Skip to main content

Ipv4Config

Struct Ipv4Config 

Source
pub struct Ipv4Config { /* private fields */ }
Available on crate feature network only.

Implementations§

Source§

impl Ipv4Config

Source

pub fn addresses(&self) -> Result<Vec<Ipv4Addr>, Error>

Examples found in repository?
examples/network.rs (line 25)
11fn main() {
12	let dbus = NetworkManager::connect().unwrap();
13
14	for device in dbus.devices().unwrap() {
15		let state = device.state().unwrap();
16		let kind = device.kind().unwrap();
17		let interface = device.interface().unwrap();
18
19		println!("{:?} {:?} {:?}", interface, kind, state);
20		if let Ok(apn) = device.modem_apn() {
21			println!("- has apn {:?}", apn);
22		}
23
24		if matches!(state, DeviceState::Activated) {
25			let ipv4 = device.ipv4_config().unwrap().addresses().unwrap();
26			println!("- addresses {:?}", ipv4);
27		}
28	}
29
30	let dbus = ModemManager::connect().unwrap();
31
32	for modem in dbus.modems().unwrap() {
33		println!(
34			"modem {:?} {:?} {:?}",
35			modem.model().unwrap(),
36			modem.manufacturer().unwrap(),
37			modem.device().unwrap()
38		);
39
40		println!(
41			"- carrier configuration: {:?}",
42			modem.carrier_configuration().unwrap()
43		);
44
45		println!(
46			"- state: {:?}, signal: {:?}",
47			modem.state().unwrap(),
48			modem.signal_quality().unwrap()
49		);
50
51		let (allowed_modes, preffered_modes) = modem.current_modes().unwrap();
52		println!(
53			"- allowed modes: 2g: {} 3g: {} 4g: {} 5g: {}",
54			allowed_modes.has_2g(),
55			allowed_modes.has_3g(),
56			allowed_modes.has_4g(),
57			allowed_modes.has_5g()
58		);
59
60		println!(
61			"- prefered modes: 2g: {} 3g: {} 4g: {} 5g: {}",
62			preffered_modes.has_2g(),
63			preffered_modes.has_3g(),
64			preffered_modes.has_4g(),
65			preffered_modes.has_5g()
66		);
67
68		println!("- bands: {:?}", modem.current_bands().unwrap());
69
70		modem.signal_setup(10).unwrap();
71		thread::sleep(Duration::from_secs(1));
72
73		if let Ok(cdma) = modem.signal_cdma() {
74			println!("- cdma: {:?}", cdma);
75		}
76
77		if let Ok(evdo) = modem.signal_evdo() {
78			println!("- evdo: {:?}", evdo);
79		}
80
81		if let Ok(gsm) = modem.signal_gsm() {
82			println!("- gsm: {:?}", gsm);
83		}
84
85		if let Ok(umts) = modem.signal_umts() {
86			println!("- umts: {:?}", umts);
87		}
88
89		if let Ok(lte) = modem.signal_lte() {
90			println!("- lte: {:?}", lte);
91		}
92
93		if let Ok(nr5g) = modem.signal_nr5g() {
94			println!("- nr5g: {:?}", nr5g);
95		}
96	}
97}

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