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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ModemMode

Source§

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

Formats the value using the given formatter. Read more
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

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 Copy for ModemMode

Source§

impl Eq for ModemMode

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.