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
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::error::*;
use std::process::Command;

#[derive(Clone, Default)]
pub struct AdbPull {
    a: bool,
    z: bool,
    disable_compression: bool,
}

impl AdbPull {
    pub fn new() -> Self {
        Self {
            ..Default::default()
        }
    }

    /// Preserve file timestamp and mode
    pub fn a(&mut self, a: bool) -> &mut Self {
        self.a = a;
        self
    }

    /// Enable compression with a specified algorithm (any, none, brotli)
    pub fn z(&mut self, z: bool) -> &mut Self {
        self.z = z;
        self
    }

    /// Disable compression
    pub fn disable_compression(&mut self, disable_compression: bool) -> &mut Self {
        self.disable_compression = disable_compression;
        self
    }

    pub fn run(&self) -> Result<()> {
        let mut pull = Command::new("adb");
        pull.arg("pull");
        if self.a {
            pull.arg("-a");
        }
        if self.z {
            pull.arg("-z");
        }
        if self.disable_compression {
            pull.arg("-Z");
        }
        Ok(())
    }
}