Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions adb_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ repository.workspace = true
rust-version.workspace = true
version.workspace = true

[features]
default = ["mdns"]
mdns = ["dep:mdns-sd"]

[dependencies]
base64 = { version = "0.22.1" }
bincode = { version = "1.3.3" }
Expand All @@ -18,9 +22,6 @@ chrono = { version = "0.4.40", default-features = false, features = ["std"] }
homedir = { version = "= 0.3.4" }
image = { version = "0.25.5", default-features = false }
log = { version = "0.4.26" }
mdns-sd = { version = "0.13.9", default-features = false, features = [
"logging",
] }
num-bigint = { version = "0.8.4", package = "num-bigint-dig" }
num-traits = { version = "0.2.19" }
quick-protobuf = { version = "0.8.1" }
Expand All @@ -39,6 +40,11 @@ serde_repr = { version = "0.1.19" }
sha1 = { version = "0.10.6", features = ["oid"] }
thiserror = { version = "2.0.7" }

# MDNS
mdns-sd = { version = "0.13.9", default-features = false, optional = true, features = [
"logging",
] }

[dev-dependencies]
anyhow = { version = "1.0.93" }
criterion = { version = "0.6.0" } # Used for benchmarks
Expand Down
1 change: 1 addition & 0 deletions adb_client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub enum RustADBError {
#[error("upgrade error: {0}")]
UpgradeError(String),
/// An error occurred while getting mdns devices
#[cfg(feature = "mdns")]
#[error(transparent)]
MDNSError(#[from] mdns_sd::Error),
/// An error occurred while sending data to channel
Expand Down
2 changes: 2 additions & 0 deletions adb_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod constants;
mod device;
mod emulator_device;
mod error;
#[cfg(feature = "mdns")]
mod mdns;
mod models;
mod server;
Expand All @@ -20,6 +21,7 @@ pub use adb_device_ext::ADBDeviceExt;
pub use device::{ADBTcpDevice, ADBUSBDevice, is_adb_device, search_adb_devices};
pub use emulator_device::ADBEmulatorDevice;
pub use error::{Result, RustADBError};
#[cfg(feature = "mdns")]
pub use mdns::*;
pub use models::{AdbStatResponse, RebootType};
pub use server::*;
Expand Down
4 changes: 4 additions & 0 deletions adb_client/src/models/adb_server_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ pub(crate) enum AdbServerCommand {
Pair(SocketAddrV4, String),
TransportAny,
TransportSerial(String),
#[cfg(feature = "mdns")]
MDNSCheck,
#[cfg(feature = "mdns")]
MDNSServices,
ServerStatus,
ReconnectOffline,
Expand Down Expand Up @@ -77,7 +79,9 @@ impl Display for AdbServerCommand {
write!(f, "reverse:forward:{remote};{local}")
}
AdbServerCommand::ReverseRemoveAll => write!(f, "reverse:killforward-all"),
#[cfg(feature = "mdns")]
AdbServerCommand::MDNSCheck => write!(f, "host:mdns:check"),
#[cfg(feature = "mdns")]
AdbServerCommand::MDNSServices => write!(f, "host:mdns:services"),
AdbServerCommand::ServerStatus => write!(f, "host:server-status"),
AdbServerCommand::Reconnect => write!(f, "reconnect"),
Expand Down
1 change: 1 addition & 0 deletions adb_client/src/server/commands/mdns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{

const OPENSCREEN_MDNS_BACKEND: &str = "ADB_MDNS_OPENSCREEN";

#[cfg(feature = "mdns")]
impl ADBServer {
/// Check if mdns discovery is available
pub fn mdns_check(&mut self) -> Result<bool> {
Expand Down
1 change: 1 addition & 0 deletions adb_client/src/server/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod connect;
mod devices;
mod disconnect;
mod kill;
#[cfg(feature = "mdns")]
mod mdns;
mod pair;
mod reconnect;
Expand Down
2 changes: 2 additions & 0 deletions adb_client/src/server/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod adb_version;
mod device_long;
mod device_short;
mod device_state;
#[cfg(feature = "mdns")]
mod mdns_services;
mod server_status;
mod wait_for_device;
Expand All @@ -10,6 +11,7 @@ pub use adb_version::AdbVersion;
pub use device_long::DeviceLong;
pub use device_short::DeviceShort;
pub use device_state::DeviceState;
#[cfg(feature = "mdns")]
pub use mdns_services::MDNSServices;
pub use server_status::{MDNSBackend, ServerStatus};
pub use wait_for_device::{WaitForDeviceState, WaitForDeviceTransport};
Loading