rust_adb/adb_host/
host_track_devices.rs

1use crate::adb_host::AsyncHostCommand;
2use crate::adb_host::AsyncHostResponse;
3use crate::adb_host::{connect, exec_command_sync, HostConnectionInfo};
4use crate::error::adb::AdbError;
5use std::time::Duration;
6
7pub struct AdbHostTrackDeviceCommand {
8    pub connection_info: HostConnectionInfo,
9}
10
11impl AsyncHostCommand for AdbHostTrackDeviceCommand {
12    fn execute(&mut self) -> Result<AsyncHostResponse, AdbError> {
13        let tcp_stream = connect(&self.connection_info)?;
14        let command = format!("host:track-devices");
15        exec_command_sync(tcp_stream, command)
16    }
17}
18
19impl AdbHostTrackDeviceCommand {
20    pub fn new(host: &String, port: &i32) -> AdbHostTrackDeviceCommand {
21        let connect_info = HostConnectionInfo {
22            host: host.clone(),
23            port: port.clone(),
24            read_timeout: None,
25            write_timeout: Option::from(Duration::from_millis(1000)),
26        };
27        AdbHostTrackDeviceCommand {
28            connection_info: connect_info,
29        }
30    }
31}