android_tools/adb/
adb_pull.rs

1use crate::error::*;
2use std::process::Command;
3
4#[derive(Clone, Default)]
5pub struct AdbPull {
6    a: bool,
7    z: bool,
8    disable_compression: bool,
9}
10
11impl AdbPull {
12    pub fn new() -> Self {
13        Self {
14            ..Default::default()
15        }
16    }
17
18    /// Preserve file timestamp and mode
19    pub fn a(&mut self, a: bool) -> &mut Self {
20        self.a = a;
21        self
22    }
23
24    /// Enable compression with a specified algorithm (any, none, brotli)
25    pub fn z(&mut self, z: bool) -> &mut Self {
26        self.z = z;
27        self
28    }
29
30    /// Disable compression
31    pub fn disable_compression(&mut self, disable_compression: bool) -> &mut Self {
32        self.disable_compression = disable_compression;
33        self
34    }
35
36    pub fn run(&self) -> Result<()> {
37        let mut pull = Command::new("adb");
38        pull.arg("pull");
39        if self.a {
40            pull.arg("-a");
41        }
42        if self.z {
43            pull.arg("-z");
44        }
45        if self.disable_compression {
46            pull.arg("-Z");
47        }
48        Ok(())
49    }
50}