List Devices
List devices reported by usbmuxd.
List devices from Rust by connecting to usbmuxd and reading the device list:
use idevice::usbmuxd::{UsbmuxdAddr, UsbmuxdConnection};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// usbmuxd tracks devices connected over USB or network.
let addr = UsbmuxdAddr::from_env_var()?;
let mut usbmuxd = UsbmuxdConnection::new(addr.to_socket().await?, 0);
for device in usbmuxd.get_devices().await? {
println!("{} ({:?})", device.udid, device.connection_type);
}
Ok(())
}Add the needed features:
[dependencies]
idevice = { version = "0.1.64", features = ["usbmuxd"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }To check the same thing from a terminal, use idevice_id:
idevice_idListen for attach and detach events:
idevice_id -lThe CLI command prints the raw device records returned by usbmuxd. The C++
example shows the same idea with one line per device.