rust_adb/adb_device/
device_shell_async.rs1use crate::adb_device::{
2 device_connection, exec_device_command_sync, AsyncDeviceCommand, AsyncDeviceProtocol,
3 DeviceConnectionInfo,
4};
5use crate::error::adb::AdbError;
6use std::time::Duration;
7
8pub struct DeviceAsyncShellCommand {
9 pub shell: String,
10 pub connection_info: DeviceConnectionInfo,
11}
12
13impl AsyncDeviceCommand for DeviceAsyncShellCommand {
14 fn execute(&mut self) -> Result<AsyncDeviceProtocol, AdbError> {
15 let tcp_stream = device_connection(&self.connection_info)?;
16 exec_device_command_sync(tcp_stream, self.shell.clone())
17 }
18}
19
20impl DeviceAsyncShellCommand {
21 pub fn new(connection_info: &DeviceConnectionInfo, shell: &String) -> DeviceAsyncShellCommand {
22 DeviceAsyncShellCommand {
23 connection_info: connection_info.clone(),
24 shell: shell.clone(),
25 }
26 }
27
28 pub fn new0(
29 host: &String, port: &i32, serial_no: &String, shell: &String,
30 ) -> DeviceAsyncShellCommand {
31 DeviceAsyncShellCommand {
32 connection_info: DeviceConnectionInfo {
33 host: host.clone(),
34 port: port.clone(),
35 serial_no: serial_no.clone(),
36 read_timeout: None,
37 write_timeout: Option::from(Duration::from_millis(1000)),
38 },
39 shell: shell.clone(),
40 }
41 }
42}