Skip to main content

ModemMode

Struct ModemMode 

Source
pub struct ModemMode(/* private fields */);
Available on crate feature network only.

Implementations§

Source§

impl ModemMode

Source

pub fn new() -> Self

Creates a new ModemNode where no mode is allowed.

Source

pub fn is_any(&self) -> bool

Any Mode is allowed, only allowed for POTS modems.

Source

pub fn set_any(&mut self)

Set the mode to Any.

Source

pub fn is_none(&self) -> bool

No Mode is allowed.

Source

pub fn has_cs(&self) -> bool

CSD, GSM, and other circuit-switched technologies.

Source

pub fn set_cs(&mut self)

Sets the CS mode (CSD, GSM, and other circuit-switched technologies).

Source

pub fn has_2g(&self) -> bool

GPRS, EDGE.

Examples found in repository?
examples/network.rs (line 54)
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}
Source

pub fn set_2g(&mut self)

Sets the 2g mode (GPRS, EDGE).

Source

pub fn has_3g(&self) -> bool

UMTS, HSxPA.

Examples found in repository?
examples/network.rs (line 55)
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}
Source

pub fn set_3g(&mut self)

Sets the 3g mode (UMTS, HSxPA).

Source

pub fn has_4g(&self) -> bool

LTE.

Examples found in repository?
examples/network.rs (line 56)
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}
Source

pub fn set_4g(&mut self)

Sets the 4g mode (LTE).

Source

pub fn has_5g(&self) -> bool

5GNR

Examples found in repository?
examples/network.rs (line 57)
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}
Source

pub fn set_5g(&mut self)

Sets the 5g mode (5GNR).

Trait Implementations§

Source§

impl Clone for ModemMode

Source§

fn clone(&self) -> ModemMode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ModemMode

Source§

impl Debug for ModemMode

Source§

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

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

impl Eq for ModemMode

Source§

impl From<ModemMode> for u32

Source§

fn from(mode: ModemMode) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for ModemMode

Source§

fn from(num: u32) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ModemMode

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ModemMode

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