1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::process::Command;

use crate::{ADBCommand, ADBResult};

/// Pair with a device for secure TCP/IP communication
pub struct ADBPair {
    ip: String,
    port: u32,
    pin: u32,
    shell: Command,
}

impl ADBPair {
    pub fn new(ip: String, port: u32, pin: u32) -> Self {
        let mut cmd = Command::new("adb");
        cmd.arg("pair");
        ADBPair {
            ip,
            port,
            pin,
            shell: cmd,
        }
    }
}

impl ADBCommand for ADBPair {
    fn build(&mut self) -> Result<&mut Command, String> {
        self.shell
            .arg(format!("{}:{}", self.ip, self.port))
            .arg(self.pin.to_string());
        Ok(&mut self.shell)
    }

    fn process_output(&self, output: ADBResult) -> ADBResult {
        output
    }
}