1 Commits

Author SHA1 Message Date
LIAUD Corentin
4126c856d9 wip: feature-based 2025-08-17 10:46:40 +02:00
7 changed files with 20 additions and 3 deletions

View File

@@ -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" }
@@ -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" }
@@ -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

View File

@@ -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

View File

@@ -9,6 +9,7 @@ mod constants;
mod device;
mod emulator_device;
mod error;
#[cfg(feature = "mdns")]
mod mdns;
mod models;
mod server;
@@ -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::*;

View File

@@ -18,7 +18,9 @@ pub(crate) enum AdbServerCommand {
Pair(SocketAddrV4, String),
TransportAny,
TransportSerial(String),
#[cfg(feature = "mdns")]
MDNSCheck,
#[cfg(feature = "mdns")]
MDNSServices,
ServerStatus,
ReconnectOffline,
@@ -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"),

View File

@@ -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> {

View File

@@ -2,6 +2,7 @@ mod connect;
mod devices;
mod disconnect;
mod kill;
#[cfg(feature = "mdns")]
mod mdns;
mod pair;
mod reconnect;

View File

@@ -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;
@@ -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};