Skip to main content

ios_core/mux/
mod.rs

1//! usbmuxd client for iOS device discovery and USB/network connection multiplexing.
2//!
3//! Provides [`MuxClient`] for connecting to usbmuxd and establishing TCP connections
4//! to device services, plus [`MuxEvent`] for real-time device attach/detach notifications.
5
6pub mod client;
7pub mod connection;
8pub mod listener;
9pub mod protocol;
10
11pub use client::MuxClient;
12pub use listener::MuxEvent;
13
14use crate::mux::protocol::DeviceEntryRaw;
15
16/// A connected iOS device discovered via usbmuxd.
17#[derive(Debug, Clone)]
18pub struct MuxDevice {
19    pub device_id: u32,
20    pub serial_number: String, // UDID
21    pub connection_type: String,
22    pub product_id: u16,
23}
24
25impl MuxDevice {
26    pub(crate) fn from_raw(raw: DeviceEntryRaw) -> Self {
27        Self {
28            device_id: raw.device_id,
29            serial_number: raw.properties.serial_number,
30            connection_type: raw.properties.connection_type,
31            product_id: raw.properties.product_id.unwrap_or(0),
32        }
33    }
34}
35
36/// Errors from usbmuxd operations.
37#[derive(Debug, thiserror::Error)]
38pub enum MuxError {
39    #[error("IO error: {0}")]
40    Io(#[from] std::io::Error),
41    #[error("protocol error: {0}")]
42    Protocol(String),
43    #[error("device not found: {0}")]
44    DeviceNotFound(String),
45}