An async-first Rust API for ModemManager over D-Bus. The goal is to provide a safe and simple high-level API for managing cellular modems on Linux systems, built on zbus for reliable D-Bus communication.
mmrs is the ModemManager counterpart to nmrs (NetworkManager) β same author, same design philosophy: typed errors, async throughout, no leaking of raw D-Bus internals into the public API.
use mmrs::ModemManager;
#[tokio::main]
async fn main() -> mmrs::Result<()> {
let mm = ModemManager::new().await?;
for modem in mm.list_modems().await? {
println!(
"{} {} β {} ({}%, {})",
modem.manufacturer, modem.model, modem.access_technologies,
modem.signal_quality, modem.state,
);
}
Ok(())
}use mmrs::{BearerConfig, IpType, ModemManager};
#[tokio::main]
async fn main() -> mmrs::Result<()> {
let mm = ModemManager::new().await?;
// Quick path: just an APN
let bearer = mm.connect_simple("internet").await?;
println!("connected on {}", bearer.interface);
// Or a full bearer configuration
let cfg = BearerConfig::new("internet")
.with_ip_type(IpType::Ipv4v6)
.with_user("user")
.with_password("hunter2");
mm.connect(&cfg).await?;
Ok(())
}use mmrs::{ModemError, ModemManager};
#[tokio::main]
async fn main() -> mmrs::Result<()> {
let mm = ModemManager::new().await?;
match mm.unlock_pin("1234").await {
Ok(()) => println!("SIM unlocked"),
Err(ModemError::WrongPin) => eprintln!("incorrect PIN"),
Err(ModemError::WrongPuk) => eprintln!("incorrect PUK, SIM may now require PUK"),
Err(e) => eprintln!("error: {e}"),
}
Ok(())
}use mmrs::ModemManager;
#[tokio::main]
async fn main() -> mmrs::Result<()> {
let mm = ModemManager::new().await?;
for modem in mm.list_modems().await? {
let scope = mm.modem(&modem.path);
let status = scope.status().await?;
println!("{}: connected = {}", modem.path, status.connected);
}
Ok(())
}Complete API documentation: docs.rs/mmrs
If something is missing that you'd like to see, please file a PR or issue, adding it to this roadmap.
- Modem enumeration and lookup by IMEI
- Primary-modem convenience helpers (
enable,disable,connect,status, ...) - Per-modem scoping via
mm.modem(path) - Signal quality and access technology (2Gβ5G, CDMA) queries
- Real-time modem/bearer state monitoring
- Location (GPS/cell-tower) support
- USSD support
- Firmware/carrier configuration management
- PIN unlock, PUK unlock, PIN enable/disable, PIN change
- Active SIM snapshot (ICCID, IMSI, operator name)
- Multi-SIM slot switching
- Simple connect via APN
- Full
BearerConfig(IP type, credentials, roaming) - Bearer snapshot with IPv4 config and stats
- IPv6 config decoding
- Manual bearer create/delete (outside
Simple.Connect)
Contributions are welcome. Please read CONTRIBUTING.md for guidelines.
- Rust: 1.90.0+
- ModemManager: Running and accessible via D-Bus
- Linux: This library is Linux-specific
This project is dual-licensed under either of the following licenses, at your option:
- MIT License
- Apache License, Version 2.0
You may use, copy, modify, and distribute this software under the terms of either license.
See the following files for full license texts: