adb_utils/commands/scripting/
get_stats.rs

1use std::process::Command;
2
3use crate::{ADBCommand, ADBResult};
4
5/// Get the state of the current device
6pub struct ADBGetState {
7    shell: Command,
8}
9
10impl Default for ADBGetState {
11    fn default() -> Self {
12        let mut cmd = Command::new("adb");
13        cmd.arg("get-state");
14
15        ADBGetState { shell: cmd }
16    }
17}
18
19impl ADBCommand for ADBGetState {
20    fn build(&mut self) -> Result<&mut Command, String> {
21        Ok(&mut self.shell)
22    }
23
24    fn process_output(&self, output: ADBResult) -> ADBResult {
25        output
26    }
27}
28
29/// Get the device's serial number(connected wired) or ip(connected wireless)
30pub struct ADBGetSerialNo {
31    shell: Command,
32}
33
34impl Default for ADBGetSerialNo {
35    fn default() -> Self {
36        let mut cmd = Command::new("adb");
37        cmd.arg("get-serialno");
38
39        ADBGetSerialNo { shell: cmd }
40    }
41}
42
43impl ADBCommand for ADBGetSerialNo {
44    fn build(&mut self) -> Result<&mut Command, String> {
45        Ok(&mut self.shell)
46    }
47
48    fn process_output(&self, output: ADBResult) -> ADBResult {
49        output
50    }
51}
52
53/// Get the device's dev path
54pub struct ADBGetDevPath {
55    shell: Command,
56}
57
58impl Default for ADBGetDevPath {
59    fn default() -> Self {
60        let mut cmd = Command::new("adb");
61        cmd.arg("get-devpath");
62
63        ADBGetDevPath { shell: cmd }
64    }
65}
66
67impl ADBCommand for ADBGetDevPath {
68    fn build(&mut self) -> Result<&mut Command, String> {
69        Ok(&mut self.shell)
70    }
71
72    fn process_output(&self, output: ADBResult) -> ADBResult {
73        output
74    }
75}