Debian Codegraph @

src/lib.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 pub mod adbrust-analyzer cargo forensic-adb 0.8.1 adb/;
6 pub mod shellrust-analyzer cargo forensic-adb 0.8.1 shell/;
7
8 #[cfg(test)]
9 pub mod testrust-analyzer cargo forensic-adb 0.8.1 test/;
10
11 use logrust-analyzer cargo log 0.4.27 crate/::{debugrust-analyzer cargo log 0.4.27 macros/debug!, tracerust-analyzer cargo log 0.4.27 macros/trace!, warnrust-analyzer cargo log 0.4.27 macros/warn!};
12 use once_cellrust-analyzer cargo once_cell 1.21.2 crate/::syncrust-analyzer cargo once_cell 1.21.2 sync/::Lazyrust-analyzer cargo once_cell 1.21.2 sync/Lazy#;
13 use regexrust-analyzer cargo regex 1.11.1 crate/::Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#;
14 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#;
15 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#;
16 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/;
17 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#;
18 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::{ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#, TryFromIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/TryFromIntError#};
19 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::{Componentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Component#, Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#};
20 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::{FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#, Utf8Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/error/Utf8Error#};
21 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#;
22 use thiserrorrust-analyzer cargo thiserror 2.0.12 crate/::Errorrust-analyzer cargo thiserror-impl 2.0.12 Error:;
23 use tokiorust-analyzer cargo tokio 1.44.1 crate/::fsrust-analyzer cargo tokio 1.44.1 fs/::Filerust-analyzer cargo tokio 1.44.1 fs/file/File#;
24 use tokiorust-analyzer cargo tokio 1.44.1 crate/::iorust-analyzer cargo tokio 1.44.1 io/::{AsyncReadrust-analyzer cargo tokio 1.44.1 io/async_read/AsyncRead#, AsyncReadExtrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#, AsyncWriterust-analyzer cargo tokio 1.44.1 io/async_write/AsyncWrite#, AsyncWriteExtrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#};
25 use tokiorust-analyzer cargo tokio 1.44.1 crate/::netrust-analyzer cargo tokio 1.44.1 net/::TcpStreamrust-analyzer cargo tokio 1.44.1 net/tcp/stream/TcpStream#;
•26 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::{Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path# as UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf# as UnixPathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#};
27 use uuidrust-analyzer cargo uuid 1.16.0 crate/::Uuidrust-analyzer cargo uuid 1.16.0 Uuid#;
28 use walkdirrust-analyzer cargo walkdir 2.5.0 crate/::WalkDirrust-analyzer cargo walkdir 2.5.0 WalkDir#;
29
30 use craterust-analyzer cargo forensic-adb 0.8.1 crate/::adbrust-analyzer cargo forensic-adb 0.8.1 adb/::{DeviceSerialrust-analyzer cargo forensic-adb 0.8.1 adb/DeviceSerial#, SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#};
31
32 pub type Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<T> = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#>;
33
34 static SYNC_REGEXrust-analyzer cargo forensic-adb 0.8.1 SYNC_REGEX.: Lazyrust-analyzer cargo once_cell 1.21.2 sync/Lazy#<Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#> = Lazyrust-analyzer cargo once_cell 1.21.2 sync/Lazy#::newrust-analyzer cargo once_cell 1.21.2 sync/impl#[`Lazy<T, F>`]new().(|| Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#::newrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]new().(r"[^A-Za-z0-9_@%+=:,./-]").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
35
36 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
37 pub enum AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput# {
38 #[defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/default:]
39 Autorust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#Auto#,
40 Apprust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#App#,
41 Internalrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#Internal#,
42 Sdcardrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#Sdcard#,
43 }
44
45 impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput# {
46 type Errrust-analyzer cargo forensic-adb 0.8.1 impl#[AndroidStorageInput][FromStr]Err# = DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#;
47
48 fn from_strrust-analyzer cargo forensic-adb 0.8.1 impl#[AndroidStorageInput][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Selfrust-analyzer cargo forensic-adb 0.8.1 impl#[AndroidStorageInput][FromStr]> {
49 match s {
50 "auto" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#::Autorust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#Auto#),
51 "app" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#::Apprust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#App#),
52 "internal" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#::Internalrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#Internal#),
53 "sdcard" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#::Sdcardrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#Sdcard#),
54 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::InvalidStoragerust-analyzer cargo forensic-adb 0.8.1 DeviceError#InvalidStorage#),
55 }
56 }
57 }
58
59 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
60 pub enum AndroidStoragerust-analyzer cargo forensic-adb 0.8.1 AndroidStorage# {
61 Apprust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#App#,
62 Internalrust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#Internal#,
63 Sdcardrust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#Sdcard#,
64 }
65
66 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Errorrust-analyzer cargo thiserror-impl 2.0.12 Error:)]
67 pub enum DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError# {
68 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("{0}")]
69 Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
70 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:(transparent)]
71 FromIntrust-analyzer cargo forensic-adb 0.8.1 DeviceError#FromInt#(#[from] TryFromIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/TryFromIntError#),
72 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("Invalid storage")]
73 InvalidStoragerust-analyzer cargo forensic-adb 0.8.1 DeviceError#InvalidStorage#,
74 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:(transparent)]
75 Iorust-analyzer cargo forensic-adb 0.8.1 DeviceError#Io#(#[from] iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#),
76 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("Missing package")]
77 MissingPackagerust-analyzer cargo forensic-adb 0.8.1 DeviceError#MissingPackage#,
78 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("Multiple Android devices online")]
79 MultipleDevicesrust-analyzer cargo forensic-adb 0.8.1 DeviceError#MultipleDevices#,
80 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:(transparent)]
81 ParseIntrust-analyzer cargo forensic-adb 0.8.1 DeviceError#ParseInt#(#[from] ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#),
82 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("Unknown Android device with serial '{0}'")]
83 UnknownDevicerust-analyzer cargo forensic-adb 0.8.1 DeviceError#UnknownDevice#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
84 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:(transparent)]
85 Utf8rust-analyzer cargo forensic-adb 0.8.1 DeviceError#Utf8#(#[from] Utf8Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/error/Utf8Error#),
86 #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:(transparent)]
87 WalkDirrust-analyzer cargo forensic-adb 0.8.1 DeviceError#WalkDir#(#[from] walkdirrust-analyzer cargo walkdir 2.5.0 crate/::Errorrust-analyzer cargo walkdir 2.5.0 error/Error#),
88 }
89
90 fn encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().(payload: &str) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
91 let hex_length = u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[u16][`TryFrom<usize>`]try_from().(payload.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|len| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:0>4X}", len))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
92
93 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}{}", hex_length, payload))
94 }
95
96 fn parse_device_inforust-analyzer cargo forensic-adb 0.8.1 parse_device_info().(line: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<DeviceInforust-analyzer cargo forensic-adb 0.8.1 DeviceInfo#> {
97 // Turn "serial\tdevice key1:value1 key2:value2 ..." into a `DeviceInfo`.
98 let mut pairs = line.split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().();
99 let serial = pairs.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`SplitWhitespace<'a>`][Iterator]next().();
100 let state = pairs.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`SplitWhitespace<'a>`][Iterator]next().();
101 if let (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(serial), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("device")) = (serial, state) {
102 let info: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = pairs
103 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|pair| {
104 let mut kv = pair.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(':');
105 if let (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(k), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) = (kv.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().(), kv.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().(), kv.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().()) {
106 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((k.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), v.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()))
107 } else {
108 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
109 }
110 })
111 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
112
113 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(DeviceInforust-analyzer cargo forensic-adb 0.8.1 DeviceInfo# {
114 serialrust-analyzer cargo forensic-adb 0.8.1 DeviceInfo#serial.: serial.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(),
115 inforust-analyzer cargo forensic-adb 0.8.1 DeviceInfo#info.,
116 })
117 } else {
118 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
119 }
120 }
121
122 /// Reads the payload length of a host message from the stream.
123 async fn read_lengthrust-analyzer cargo forensic-adb 0.8.1 read_length().<R: AsyncReadrust-analyzer cargo tokio 1.44.1 io/async_read/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#>(stream: &mut R) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<usize> {
124 let mut bytes: [u8; 4] = [0; 4];
125 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut bytes).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
126
127 let response = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
128
129 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(usize::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]from_str_radix().(response, 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
130 }
131
132 /// Reads the payload length of a device message from the stream.
133 async fn read_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 read_length_little_endian().<R: AsyncReadrust-analyzer cargo tokio 1.44.1 io/async_read/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#>(reader: &mut R) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<usize> {
134 let mut bytes: [u8; 4] = [0; 4];
135 reader.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut bytes).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
136
137 let n: usize = (bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). as usize)
138 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().((bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). as usize) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().8)
139 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().((bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). as usize) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().16)
140 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().((bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). as usize) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().24);
141
142 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n)
143 }
144
145 /// Writes the payload length of a device message to the stream.
146 async fn write_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 write_length_little_endian().<W: AsyncWriterust-analyzer cargo tokio 1.44.1 io/async_write/AsyncWrite# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#>(
147 writer: &mut W,
148 n: usize,
149 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<usize> {
150 let mut bytes = [0; 4];
151 bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = (n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().0xFF) as u8;
152 bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = ((n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().8) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().0xFF) as u8;
153 bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = ((n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().16) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().0xFF) as u8;
154 bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = ((n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().24) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().0xFF) as u8;
155
156 writer.writerust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write().(&bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().).rust-analyzer cargo tokio 1.44.1 io/util/write/impl#[`Write<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write/impl#[`Write<'_, W>`][Future]poll()..map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Iorust-analyzer cargo forensic-adb 0.8.1 DeviceError#Io#)
157 }
158
159 async fn read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(
160 stream: &mut TcpStreamrust-analyzer cargo tokio 1.44.1 net/tcp/stream/TcpStream#,
161 has_output: bool,
162 has_length: bool,
163 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> {
164 let mut bytes: [u8; 1024] = [0; 1024];
165
166 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
167
168 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bytes.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]starts_with().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Okayrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Okay#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()) {
169 let n = bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(read_lengthrust-analyzer cargo forensic-adb 0.8.1 read_length().(stream).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
170 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
171
172 let message = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&bytes[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|s| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("adb error: {}", s))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
173
174 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#(message));
175 }
176
177 let mut response = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
178
179 if has_output {
180 stream.read_to_endrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_to_end().(&mut response).rust-analyzer cargo tokio 1.44.1 io/util/read_to_end/impl#[`ReadToEnd<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_to_end/impl#[`ReadToEnd<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
181
182 if response.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]starts_with().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Okayrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Okay#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()) {
183 // Sometimes the server produces OKAYOKAY. Sometimes there is a transport OKAY and
184 // then the underlying command OKAY. This is straight from `chromedriver`.
185 response = response.split_offrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]split_off().(4);
186 }
187
188 if response.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]starts_with().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Failrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Fail#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()) {
189 // The server may even produce OKAYFAIL, which means the underlying
190 // command failed. First split-off the `FAIL` and length of the message.
191 response = response.split_offrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]split_off().(8);
192
193 let message = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&response).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|s| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("adb error: {}", s))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
194
195 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#(message));
196 }
197
198 if has_length {
199 if response.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().4 {
200 let message = response.split_offrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]split_off().(4);
201 let slice: &mut &[u8] = &mut &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Deref]deref().response;
202
203 let n = read_lengthrust-analyzer cargo forensic-adb 0.8.1 read_length().(slice).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
204 if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().message.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
205 warnrust-analyzer cargo log 0.4.27 macros/warn!!(
206 "adb server response contained hexstring len {} but remaining message length is {}",
207 n,
208 message.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()
209 );
210 }
211
212 tracerust-analyzer cargo log 0.4.27 macros/trace!!(
213 "adb server response was {:?}",
214 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&message)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
215 );
216
217 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(message);
218 } else {
219 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
220 "adb server response did not contain expected hexstring length: {:?}",
221 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&response)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
222 )));
223 }
224 }
225 }
226
227 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(response)
228 }
229
230 /// Detailed information about an ADB device.
231 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
232 pub struct DeviceInforust-analyzer cargo forensic-adb 0.8.1 DeviceInfo# {
233 pub serialrust-analyzer cargo forensic-adb 0.8.1 DeviceInfo#serial.: DeviceSerialrust-analyzer cargo forensic-adb 0.8.1 adb/DeviceSerial#,
234 pub inforust-analyzer cargo forensic-adb 0.8.1 DeviceInfo#info.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
235 }
236
237 /// Represents a connection to an ADB host, which multiplexes the connections to
238 /// individual devices.
239 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
240 pub struct Hostrust-analyzer cargo forensic-adb 0.8.1 Host# {
241 /// The TCP host to connect to. Defaults to `"localhost"`.
242 pub hostrust-analyzer cargo forensic-adb 0.8.1 Host#host.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
243 /// The TCP port to connect to. Defaults to `5037`.
244 pub portrust-analyzer cargo forensic-adb 0.8.1 Host#port.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u16>,
245 }
246
247 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Hostrust-analyzer cargo forensic-adb 0.8.1 Host# {
248 fn defaultrust-analyzer cargo forensic-adb 0.8.1 impl#[Host][Default]default().() -> Hostrust-analyzer cargo forensic-adb 0.8.1 Host# {
249 Hostrust-analyzer cargo forensic-adb 0.8.1 Host# {
250 hostrust-analyzer cargo forensic-adb 0.8.1 Host#host.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("localhost".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
251 portrust-analyzer cargo forensic-adb 0.8.1 Host#port.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5037),
252 }
253 }
254 }
255
256 impl Hostrust-analyzer cargo forensic-adb 0.8.1 Host# {
257 /// Searches for available devices, and selects the one as specified by `device_serial`.
258 ///
259 /// If multiple devices are online, and no device has been specified,
260 /// the `ANDROID_SERIAL` environment variable can be used to select one.
261 pub async fn device_or_defaultrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]device_or_default().<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(
262 self,
263 device_serial: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&T>,
264 storage: AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#,
265 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Devicerust-analyzer cargo forensic-adb 0.8.1 Device#> {
266 let serials: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = self
267 .devicesrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]devices().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
268 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
269 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
270 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|d| d.serialrust-analyzer cargo forensic-adb 0.8.1 DeviceInfo#serial.)
271 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
272
273 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref serial) = device_serial
274 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| v.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())
275 .or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]or_else().(|| stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("ANDROID_SERIAL").okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().())
276 {
277 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().serials.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(serial) {
278 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::UnknownDevicerust-analyzer cargo forensic-adb 0.8.1 DeviceError#UnknownDevice#(serial.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()));
279 }
280
281 return Devicerust-analyzer cargo forensic-adb 0.8.1 Device#::newrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]new().(self, serial.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().(), storage).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
282 }
283
284 if serials.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().1 {
285 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::MultipleDevicesrust-analyzer cargo forensic-adb 0.8.1 DeviceError#MultipleDevices#);
286 }
287
288 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref serial) = serials.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().() {
289 return Devicerust-analyzer cargo forensic-adb 0.8.1 Device#::newrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]new().(self, serial.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), storage).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
290 }
291
292 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#("No Android devices are online".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()))
293 }
294
295 pub async fn connectrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]connect().(&self) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<TcpStreamrust-analyzer cargo tokio 1.44.1 net/tcp/stream/TcpStream#> {
296 let stream = TcpStreamrust-analyzer cargo tokio 1.44.1 net/tcp/stream/TcpStream#::connectrust-analyzer cargo tokio 1.44.1 net/tcp/stream/impl#[TcpStream]connect().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
297 "{}:{}",
298 self.hostrust-analyzer cargo forensic-adb 0.8.1 Host#host..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| "localhost".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()),
299 self.portrust-analyzer cargo forensic-adb 0.8.1 Host#port..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(5037)
300 ))
301 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
302 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(stream)
303 }
304
305 pub async fn execute_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]execute_command().(
306 &self,
307 command: &str,
308 has_output: bool,
309 has_length: bool,
310 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
311 let mut stream = self.connectrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]connect().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
312
313 stream
314 .write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().(command)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().())
315 .rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
316 let bytes = read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(&mut stream, has_output, has_length).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
317 // TODO: should we assert no bytes were read?
318
319 let response = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
320
321 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(response.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())
322 }
323
324 pub async fn execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]execute_host_command().(
325 &self,
326 host_command: &str,
327 has_length: bool,
328 has_output: bool,
329 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
330 self.execute_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]execute_command().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("host:{}", host_command), has_output, has_length)
331 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
332 }
333
334 pub async fn featuresrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]features().<B: FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>(&self) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<B> {
335 let features = self.execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]execute_host_command().("features", true, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
336 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(features.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|x| x.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().())
337 }
338
339 pub async fn devicesrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]devices().<B: FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<DeviceInforust-analyzer cargo forensic-adb 0.8.1 DeviceInfo#>>(&self) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<B> {
340 let response = self.execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]execute_host_command().("devices-l", true, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
341
342 let infos: B = response.linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(parse_device_inforust-analyzer cargo forensic-adb 0.8.1 parse_device_info().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
343
344 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(infos)
345 }
346 }
347
348 /// Represents an ADB device.
349 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
350 pub struct Devicerust-analyzer cargo forensic-adb 0.8.1 Device# {
351 /// ADB host that controls this device.
352 pub hostrust-analyzer cargo forensic-adb 0.8.1 Device#host.: Hostrust-analyzer cargo forensic-adb 0.8.1 Host#,
353
354 /// Serial number uniquely identifying this ADB device.
355 pub serialrust-analyzer cargo forensic-adb 0.8.1 Device#serial.: DeviceSerialrust-analyzer cargo forensic-adb 0.8.1 adb/DeviceSerial#,
356
357 pub run_as_packagerust-analyzer cargo forensic-adb 0.8.1 Device#run_as_package.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
358
359 pub storagerust-analyzer cargo forensic-adb 0.8.1 Device#storage.: AndroidStoragerust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#,
360
361 /// Cache intermediate tempfile name used in pushing via run_as.
362 pub tempfilerust-analyzer cargo forensic-adb 0.8.1 Device#tempfile.: UnixPathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#,
363 }
364
365 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
366 pub struct RemoteDirEntryrust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry# {
367 pub depthrust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#depth.: usize,
368 pub metadatarust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#metadata.: RemoteMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#,
369 pub namerust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
370 }
371
372 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
373 pub enum RemoteMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata# {
374 RemoteFilerust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteFile#(RemoteFileMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteFileMetadata#),
375 RemoteDirrust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteDir#,
376 RemoteSymlinkrust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteSymlink#,
377 }
378 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
379 pub struct RemoteFileMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteFileMetadata# {
380 pub moderust-analyzer cargo forensic-adb 0.8.1 RemoteFileMetadata#mode.: usize,
381 pub sizerust-analyzer cargo forensic-adb 0.8.1 RemoteFileMetadata#size.: usize,
382 }
383
384 impl Devicerust-analyzer cargo forensic-adb 0.8.1 Device# {
385 pub async fn newrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]new().(
386 host: Hostrust-analyzer cargo forensic-adb 0.8.1 Host#,
387 serial: DeviceSerialrust-analyzer cargo forensic-adb 0.8.1 adb/DeviceSerial#,
388 storage: AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#,
389 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Devicerust-analyzer cargo forensic-adb 0.8.1 Device#> {
390 let mut device = Devicerust-analyzer cargo forensic-adb 0.8.1 Device# {
391 hostrust-analyzer cargo forensic-adb 0.8.1 Device#host.,
392 serialrust-analyzer cargo forensic-adb 0.8.1 Device#serial.,
393 run_as_packagerust-analyzer cargo forensic-adb 0.8.1 Device#run_as_package.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
394 storagerust-analyzer cargo forensic-adb 0.8.1 Device#storage.: AndroidStoragerust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#::Apprust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#App#,
395 tempfilerust-analyzer cargo forensic-adb 0.8.1 Device#tempfile.: UnixPathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/data/local/tmp"),
396 };
397 device
398 .tempfilerust-analyzer cargo forensic-adb 0.8.1 Device#tempfile.
399 .pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(Uuidrust-analyzer cargo uuid 1.16.0 Uuid#::new_v4rust-analyzer cargo uuid 1.16.0 v4/impl#[Uuid]new_v4().().as_hyphenatedrust-analyzer cargo uuid 1.16.0 fmt/impl#[Uuid]as_hyphenated().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
400
401 device.storagerust-analyzer cargo forensic-adb 0.8.1 Device#storage. = match storage {
402 AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#::Apprust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#App# => AndroidStoragerust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#::Apprust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#App#,
403 AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#::Internalrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#Internal# => AndroidStoragerust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#::Internalrust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#Internal#,
404 AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#::Sdcardrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#Sdcard# => AndroidStoragerust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#::Sdcardrust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#Sdcard#,
405 AndroidStorageInputrust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#::Autorust-analyzer cargo forensic-adb 0.8.1 AndroidStorageInput#Auto# => AndroidStoragerust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#::Sdcardrust-analyzer cargo forensic-adb 0.8.1 AndroidStorage#Sdcard#,
406 };
407
408 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(device)
409 }
410
411 pub async fn clear_app_datarust-analyzer cargo forensic-adb 0.8.1 impl#[Device]clear_app_data().(&self, package: &str) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<bool> {
412 self.execute_host_shell_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("pm clear {}", package))
413 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
414 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|v| v.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Success"))
415 }
416
417 pub async fn create_dirrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]create_dir().(&self, path: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
418 debugrust-analyzer cargo log 0.4.27 macros/debug!!("Creating {}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
419
420 let enable_run_as = self.enable_run_as_for_pathrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]enable_run_as_for_path().(path);
421 self.execute_host_shell_command_asrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command_as().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("mkdir -p {}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().()), enable_run_as)
422 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
423
424 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
425 }
426
427 pub async fn chmodrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]chmod().(&self, path: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, mask: &str, recursive: bool) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
428 let enable_run_as = self.enable_run_as_for_pathrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]enable_run_as_for_path().(path);
429
430 let recursive = match recursive {
431 true => " -R",
432 false => "",
433 };
434
435 self.execute_host_shell_command_asrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command_as().(
436 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("chmod {} {} {}", recursive, mask, path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().()),
437 enable_run_as,
438 )
439 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
440
441 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
442 }
443
444 pub async fn execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command().(
445 &self,
446 command: &str,
447 has_output: bool,
448 has_length: bool,
449 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> {
450 let mut stream = self.hostrust-analyzer cargo forensic-adb 0.8.1 Device#host..connectrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]connect().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
451
452 let switch_command = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("host:transport:{}", self.serialrust-analyzer cargo forensic-adb 0.8.1 Device#serial.);
453 tracerust-analyzer cargo log 0.4.27 macros/trace!!("execute_host_command: >> {:?}", &switch_command);
454 stream
455 .write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().(&switch_command)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().())
456 .rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
457 let _bytes = read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(&mut stream, false, false).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
458 tracerust-analyzer cargo log 0.4.27 macros/trace!!("execute_host_command: << {:?}", _bytes);
459 // TODO: should we assert no bytes were read?
460
461 tracerust-analyzer cargo log 0.4.27 macros/trace!!("execute_host_command: >> {:?}", &command);
462 stream
463 .write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().(command)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().())
464 .rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
465 let bytes = read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(&mut stream, has_output, has_length).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
466 tracerust-analyzer cargo log 0.4.27 macros/trace!!("execute_host_command: << {:?}", bstrrust-analyzer cargo bstr 1.11.3 crate/::BStrrust-analyzer cargo bstr 1.11.3 bstr/BStr#::newrust-analyzer cargo bstr 1.11.3 bstr/impl#[BStr]new().(&bytes));
467
468 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bytes)
469 }
470
471 pub async fn execute_host_command_to_stringrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command_to_string().(
472 &self,
473 command: &str,
474 has_output: bool,
475 has_length: bool,
476 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
477 let bytes = self
478 .execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command().(command, has_output, has_length)
479 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
480
481 let response = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
482
483 // Unify new lines by removing possible carriage returns
484 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(response.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("\r\n", "\n"))
485 }
486
487 pub fn enable_run_as_for_pathrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]enable_run_as_for_path().(&self, path: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> bool {
488 match &self.run_as_packagerust-analyzer cargo forensic-adb 0.8.1 Device#run_as_package. {
489 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(package) => {
490 let mut p = UnixPathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/data/data/");
491 p.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(package);
492 path.starts_withrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]starts_with().(p)
493 }
494 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => false,
495 }
496 }
497
498 pub async fn execute_host_shell_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command().(&self, shell_command: &str) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
499 self.execute_host_shell_command_asrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command_as().(shell_command, false)
500 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
501 }
502
503 pub async fn execute_host_exec_out_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_exec_out_command().(&self, shell_command: &str) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> {
504 self.execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("exec:{}", shell_command), true, false)
505 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
506 }
507
508 pub async fn execute_host_shell_command_asrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command_as().(
509 &self,
510 shell_command: &str,
511 enable_run_as: bool,
512 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
513 // We don't want to duplicate su invocations.
514 if shell_command.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("su") {
515 return self
516 .execute_host_command_to_stringrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command_to_string().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("shell:{}", shell_command), true, false)
517 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
518 }
519
520 let has_outer_quotes = shell_command.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('"') && shell_command.ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().('"')
521 || shell_command.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('\'') && shell_command.ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().('\'');
522
523 // Execute command as package
524 if enable_run_as {
525 let run_as_package = self
526 .run_as_packagerust-analyzer cargo forensic-adb 0.8.1 Device#run_as_package.
527 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
528 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::MissingPackagerust-analyzer cargo forensic-adb 0.8.1 DeviceError#MissingPackage#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
529
530 if has_outer_quotes {
531 return self
532 .execute_host_command_to_stringrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command_to_string().(
533 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("shell:run-as {} {}", run_as_package, shell_command),
534 true,
535 false,
536 )
537 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
538 }
539
540 if SYNC_REGEXrust-analyzer cargo forensic-adb 0.8.1 SYNC_REGEX..is_matchrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]is_match().(shell_command) {
541 let arg: &str = &shell_command.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('\'', "'\"'\"'")[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().;
542 return self
543 .execute_host_command_to_stringrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command_to_string().(
544 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("shell:run-as {} {}", run_as_package, arg),
545 true,
546 false,
547 )
548 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
549 }
550
551 return self
552 .execute_host_command_to_stringrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command_to_string().(
553 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("shell:run-as {} \"{}\"", run_as_package, shell_command),
554 true,
555 false,
556 )
557 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
558 }
559
560 self.execute_host_command_to_stringrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command_to_string().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("shell:{}", shell_command), true, false)
561 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
562 }
563
564 pub async fn is_app_installedrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]is_app_installed().(&self, package: &str) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<bool> {
565 self.execute_host_shell_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("pm path {}", package))
566 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
567 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|v| v.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("package:"))
568 }
569
570 pub async fn launchrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]launch().<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(
571 &self,
572 package: &str,
573 activity: &str,
574 am_start_args: &[T],
575 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<bool> {
576 let mut am_start = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("am start -W -n {}/{}", package, activity);
577
578 for arg in am_start_args {
579 am_start.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
580 if SYNC_REGEXrust-analyzer cargo forensic-adb 0.8.1 SYNC_REGEX..is_matchrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]is_match().(arg.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()) {
581 am_start.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("\"{}\"", &shellrust-analyzer cargo forensic-adb 0.8.1 shell/::escaperust-analyzer cargo forensic-adb 0.8.1 shell/escape().(arg.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().())));
582 } else {
583 am_start.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&shellrust-analyzer cargo forensic-adb 0.8.1 shell/::escaperust-analyzer cargo forensic-adb 0.8.1 shell/escape().(arg.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()));
584 };
585 }
586
587 self.execute_host_shell_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command().(&am_start)
588 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
589 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|v| v.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Complete"))
590 }
591
592 pub async fn force_stoprust-analyzer cargo forensic-adb 0.8.1 impl#[Device]force_stop().(&self, package: &str) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
593 debugrust-analyzer cargo log 0.4.27 macros/debug!!("Force stopping Android package: {}", package);
594 self.execute_host_shell_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("am force-stop {}", package))
595 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
596 .andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and().(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()))
597 }
598
599 pub async fn forward_portrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]forward_port().(&self, local: u16, remote: u16) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<u16> {
600 let command = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
601 "host-serial:{}:forward:tcp:{};tcp:{}",
602 self.serialrust-analyzer cargo forensic-adb 0.8.1 Device#serial., local, remote
603 );
604 let response = self.hostrust-analyzer cargo forensic-adb 0.8.1 Device#host..execute_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]execute_command().(&command, true, false).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
605
606 if local rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0 {
607 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(response.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<u16>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
608 } else {
609 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(local)
610 }
611 }
612
613 pub async fn kill_forward_portrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]kill_forward_port().(&self, local: u16) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
614 let command = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("host-serial:{}:killforward:tcp:{}", self.serialrust-analyzer cargo forensic-adb 0.8.1 Device#serial., local);
615 self.execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command().(&command, true, false)
616 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
617 .andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and().(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()))
618 }
619
620 pub async fn kill_forward_all_portsrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]kill_forward_all_ports().(&self) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
621 let command = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("host-serial:{}:killforward-all", self.serialrust-analyzer cargo forensic-adb 0.8.1 Device#serial.);
622 self.execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command().(&command, false, false)
623 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
624 .andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and().(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()))
625 }
626
627 pub async fn reverse_portrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]reverse_port().(&self, remote: u16, local: u16) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<u16> {
628 let command = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("reverse:forward:tcp:{};tcp:{}", remote, local);
629 let response = self
630 .execute_host_command_to_stringrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command_to_string().(&command, true, false)
631 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
632
633 if remote rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0 {
634 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(response.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<u16>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
635 } else {
636 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(remote)
637 }
638 }
639
640 pub async fn kill_reverse_portrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]kill_reverse_port().(&self, remote: u16) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
641 let command = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("reverse:killforward:tcp:{}", remote);
642 self.execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command().(&command, true, true)
643 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
644 .andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and().(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()))
645 }
646
647 pub async fn kill_reverse_all_portsrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]kill_reverse_all_ports().(&self) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
648 let command = "reverse:killforward-all".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
649 self.execute_host_commandrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_command().(&command, false, false)
650 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
651 .andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and().(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()))
652 }
653
654 pub async fn list_dirrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]list_dir().(&self, src: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<RemoteDirEntryrust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#>> {
655 let src = src.to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().();
656 let mut queue = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(src.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().(), 0, "".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())];
657
658 let mut listings = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
659
660 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((next, depth, prefix)) = queue.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().() {
661 for listing in self.list_dir_flatrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]list_dir_flat().(&next, depth, prefix).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
662 if listing.metadatarust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#metadata. rust-analyzer cargo forensic-adb 0.8.1 impl#[RemoteMetadata][`PartialEq<Self>`]eq().==rust-analyzer cargo forensic-adb 0.8.1 impl#[RemoteMetadata][`PartialEq<Self>`]eq(). rust-analyzer cargo forensic-adb 0.8.1 impl#[RemoteMetadata][`PartialEq<Self>`]eq().RemoteMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#::RemoteDirrust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteDir# {
663 let mut child = src.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().();
664 child.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(listing.namerust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#name..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().());
665 queue.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((child, depth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, listing.namerust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#name..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()));
666 }
667
668 listings.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(listing);
669 }
670 }
671
672 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(listings)
673 }
674
675 async fn list_dir_flatrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]list_dir_flat().(
676 &self,
677 src: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#,
678 depth: usize,
679 prefix: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
680 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<RemoteDirEntryrust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#>> {
681 // Implement the ADB protocol to list a directory from the device.
682 let mut stream = self.hostrust-analyzer cargo forensic-adb 0.8.1 Device#host..connectrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]connect().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
683
684 // Send "host:transport" command with device serial
685 let message = encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("host:transport:{}", self.serialrust-analyzer cargo forensic-adb 0.8.1 Device#serial.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
686 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(message.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
687 let _bytes = read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(&mut stream, false, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
688
689 // Send "sync:" command to initialize file transfer
690 let message = encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().("sync:")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
691 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(message.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
692 let _bytes = read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(&mut stream, false, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
693
694 // Send "LIST" command with name of the directory
695 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Listrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#List#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
696 let args_ = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", src.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
697 let args = args_.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().();
698 write_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 write_length_little_endian().(&mut stream, args.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
699 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(args).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
700
701 // Use the maximum 64KB buffer to transfer the file contents.
702 let mut buf = [0; 64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().1024];
703
704 let mut listings = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
705
706 // Read "DENT" command one or more times for the directory entries
707 loop {
708 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
709
710 if &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Dentrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Dent#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().() {
711 // From https://github.com/cstyan/adbDocumentation/blob/6d025b3e4af41be6f93d37f516a8ac7913688623/README.md:
712 //
713 // A four-byte integer representing file mode - first 9 bits of this mode represent
714 // the file permissions, as with chmod mode. Bits 14 to 16 seem to represent the
715 // file type, one of 0b100 (file), 0b010 (directory), 0b101 (symlink)
716 // A four-byte integer representing file size.
717 // A four-byte integer representing last modified time in seconds since Unix Epoch.
718 // A four-byte integer representing file name length.
719 // A utf-8 string representing the file name.
720 let mode = read_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 read_length_little_endian().(&mut stream).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
721 let size = read_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 read_length_little_endian().(&mut stream).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
722 let _time = read_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 read_length_little_endian().(&mut stream).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
723 let name_length = read_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 read_length_little_endian().(&mut stream).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
724 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#name_length]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
725
726 let mut name = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#name_length]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
727
728 if name rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."." || name rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().".." {
729 continue;
730 }
731
732 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().prefix.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
733 name = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}/{}", prefix, &name);
734 }
735
736 let file_type = (mode rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().13) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().0b111;
737 let metadata = match file_type {
738 0b010 => RemoteMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#::RemoteDirrust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteDir#,
739 0b100 => RemoteMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#::RemoteFilerust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteFile#(RemoteFileMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteFileMetadata# {
740 moderust-analyzer cargo forensic-adb 0.8.1 RemoteFileMetadata#mode.: mode rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().0b111111111,
741 sizerust-analyzer cargo forensic-adb 0.8.1 RemoteFileMetadata#size.,
742 }),
743 0b101 => RemoteMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#::RemoteSymlinkrust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteSymlink#,
744 _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Invalid file mode {}", file_type))),
745 };
746
747 listings.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(RemoteDirEntryrust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry# {
748 namerust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#name.,
749 depthrust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#depth.,
750 metadatarust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#metadata.,
751 });
752 } else if &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Donerust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Done#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().() {
753 // "DONE" command indicates end of file transfer
754 break;
755 } else if &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Failrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Fail#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().() {
756 let n = buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(read_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 read_length_little_endian().(&mut stream).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
757
758 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
759
760 let message = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().)
761 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|s| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("adb error: {}", s))
762 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|_| "adb error was not utf-8".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
763
764 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#(message));
765 } else {
766 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#("FAIL (unknown)".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()));
767 }
768 }
769
770 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(listings)
771 }
772
773 pub async fn path_existsrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]path_exists().(&self, path: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, enable_run_as: bool) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<bool> {
774 self.execute_host_shell_command_asrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command_as().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("ls {}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().()).as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(), enable_run_as)
775 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
776 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|path| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().path.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("No such file or directory"))
777 }
778
779 pub async fn pullrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]pull().<W: AsyncWriterust-analyzer cargo tokio 1.44.1 io/async_write/AsyncWrite# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#>(&self, src: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, buffer: &mut W) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
780 // Implement the ADB protocol to receive a file from the device.
781 let mut stream = self.hostrust-analyzer cargo forensic-adb 0.8.1 Device#host..connectrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]connect().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
782
783 // Send "host:transport" command with device serial
784 let message = encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("host:transport:{}", self.serialrust-analyzer cargo forensic-adb 0.8.1 Device#serial.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
785 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(message.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
786 let _bytes = read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(&mut stream, false, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
787
788 // Send "sync:" command to initialize file transfer
789 let message = encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().("sync:")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
790 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(message.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
791 let _bytes = read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(&mut stream, false, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
792
793 // Send "RECV" command with name of the file
794 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Recvrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Recv#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
795 let args_string = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", src.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
796 let args = args_string.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().();
797 write_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 write_length_little_endian().(&mut stream, args.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
798 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(args).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
799
800 // Use the maximum 64KB buffer to transfer the file contents.
801 let mut buf = [0; 64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().1024];
802
803 // Read "DATA" command one or more times for the file content
804 loop {
805 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
806
807 if &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Datarust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Data#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().() {
808 let len = read_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 read_length_little_endian().(&mut stream).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
809 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
810 buffer.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
811 } else if &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Donerust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Done#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().() {
812 // "DONE" command indicates end of file transfer
813 break;
814 } else if &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Failrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Fail#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().() {
815 let n = buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(read_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 read_length_little_endian().(&mut stream).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
816
817 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
818
819 let message = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().)
820 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|s| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("adb error: {}", s))
821 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|_| "adb error was not utf-8".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
822
823 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#(message));
824 } else {
825 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#("FAIL (unknown)".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()));
826 }
827 }
828
829 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
830 }
831
832 pub async fn pull_dirrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]pull_dir().(&self, src: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, dest_dir: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
833 let src = src.to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().();
834 let dest_dir = dest_dir.to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().();
835
836 for entry in self.list_dirrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]list_dir().(&src).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
837 match entry.metadatarust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#metadata. {
838 RemoteMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#::RemoteSymlinkrust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteSymlink# => {} // Ignored.
839 RemoteMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#::RemoteDirrust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteDir# => {
840 let mut d = dest_dir.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().();
841 d.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(&entry.namerust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#name.);
842
843 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::create_dir_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/create_dir_all().(&d)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
844 }
845 RemoteMetadatarust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#::RemoteFilerust-analyzer cargo forensic-adb 0.8.1 RemoteMetadata#RemoteFile#(_) => {
846 let mut s = src.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().();
847 s.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(&entry.namerust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#name.);
848 let mut d = dest_dir.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().();
849 d.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(&entry.namerust-analyzer cargo forensic-adb 0.8.1 RemoteDirEntry#name.);
850
851 self.pullrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]pull().(&s, &mut Filerust-analyzer cargo tokio 1.44.1 fs/file/File#::createrust-analyzer cargo tokio 1.44.1 fs/file/impl#[File]create().(d).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
852 }
853 }
854 }
855
856 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
857 }
858
859 pub async fn pushrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]push().<R: AsyncReadrust-analyzer cargo tokio 1.44.1 io/async_read/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#>(
860 &self,
861 buffer: &mut R,
862 dest: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#,
863 mode: u32,
864 ) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
865 // Implement the ADB protocol to send a file to the device.
866 // The protocol consists of the following steps:
867 // * Send "host:transport" command with device serial
868 // * Send "sync:" command to initialize file transfer
869 // * Send "SEND" command with name and mode of the file
870 // * Send "DATA" command one or more times for the file content
871 // * Send "DONE" command to indicate end of file transfer
872
873 let enable_run_as = self.enable_run_as_for_pathrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]enable_run_as_for_path().(&dest.to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().());
874 let dest1 = match enable_run_as {
875 true => self.tempfilerust-analyzer cargo forensic-adb 0.8.1 Device#tempfile..as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
876 false => UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().(dest),
877 };
878
879 // If the destination directory does not exist, adb will
880 // create it and any necessary ancestors however it will not
881 // set the directory permissions to 0o777. In addition,
882 // Android 9 (P) has a bug in its push implementation which
883 // will cause a push which creates directories to fail with
884 // the error `secure_mkdirs failed: Operation not
885 // permitted`. We can work around this by creating the
886 // destination directories prior to the push. Collect the
887 // ancestors of the destination directory which do not yet
888 // exist so we can create them and adjust their permissions
889 // prior to performing the push.
890 let mut current = dest.parentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]parent().();
891 let mut leaf: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
892 let mut root: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
893
894 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path) = current {
895 if self.path_existsrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]path_exists().(path, enable_run_as).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
896 break;
897 }
898 if leaf.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() {
899 leaf = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path);
900 }
901 root = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path);
902 current = path.parentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]parent().();
903 }
904
905 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path) = leaf {
906 self.create_dirrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]create_dir().(path).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
907 }
908
909 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path) = root {
910 self.chmodrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]chmod().(path, "777", true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
911 }
912
913 let mut stream = self.hostrust-analyzer cargo forensic-adb 0.8.1 Device#host..connectrust-analyzer cargo forensic-adb 0.8.1 impl#[Host]connect().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
914
915 let message = encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("host:transport:{}", self.serialrust-analyzer cargo forensic-adb 0.8.1 Device#serial.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
916 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(message.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
917 let _bytes = read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(&mut stream, false, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
918
919 let message = encode_messagerust-analyzer cargo forensic-adb 0.8.1 encode_message().("sync:")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
920 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(message.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
921 let _bytes = read_responserust-analyzer cargo forensic-adb 0.8.1 read_response().(&mut stream, false, true).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
922
923 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Sendrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Send#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
924 let args_ = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{},{}", dest1.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), mode);
925 let args = args_.as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().();
926 write_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 write_length_little_endian().(&mut stream, args.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
927 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(args).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
928
929 // Use a 32KB buffer to transfer the file contents
930 // TODO: Maybe adjust to maxdata (256KB)
931 let mut buf = [0; 32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().1024];
932
933 loop {
934 let len = buffer.readrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read().(&mut buf).rust-analyzer cargo tokio 1.44.1 io/util/read/impl#[`Read<'_, R>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read/impl#[`Read<'_, R>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
935
936 if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
937 break;
938 }
939
940 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Datarust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Data#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
941 write_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 write_length_little_endian().(&mut stream, len).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
942 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
943 }
944
945 // https://android.googlesource.com/platform/system/core/+/master/adb/SYNC.TXT#66
946 //
947 // When the file is transferred a sync request "DONE" is sent, where length is set
948 // to the last modified time for the file. The server responds to this last
949 // request (but not to chunk requests) with an "OKAY" sync response (length can
950 // be ignored).
951 let time: u32 = ((SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]now().().duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]duration_since().(SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#::UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]UNIX_EPOCH.))
952 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
953 .as_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs().()
954 &rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand().0xFFFF_FFFF) as u32;
955
956 stream.write_allrust-analyzer cargo tokio 1.44.1 io/util/async_write_ext/AsyncWriteExt#write_all().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Donerust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Done#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()).rust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/write_all/impl#[`WriteAll<'_, W>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
957 write_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 write_length_little_endian().(&mut stream, time as usize).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
958
959 // Status.
960 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
961
962 if buf.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]starts_with().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Okayrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Okay#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()) {
963 if enable_run_as {
964 // Use cp -a to preserve the permissions set by push.
965 let result = self
966 .execute_host_shell_command_asrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command_as().(
967 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("cp -aR {} {}", dest1.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), dest.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().()).as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(),
968 enable_run_as,
969 )
970 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
971 if self.removerust-analyzer cargo forensic-adb 0.8.1 impl#[Device]remove().(dest1).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() {
972 warnrust-analyzer cargo log 0.4.27 macros/warn!!("Failed to remove {}", dest1.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
973 }
974 result?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
975 }
976 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
977 } else if buf.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]starts_with().(SyncCommandrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#::Failrust-analyzer cargo forensic-adb 0.8.1 adb/SyncCommand#Fail#.coderust-analyzer cargo forensic-adb 0.8.1 adb/impl#[SyncCommand]code().()) {
978 if enable_run_as && self.removerust-analyzer cargo forensic-adb 0.8.1 impl#[Device]remove().(dest1).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() {
979 warnrust-analyzer cargo log 0.4.27 macros/warn!!("Failed to remove {}", dest1.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
980 }
981 let n = buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(read_length_little_endianrust-analyzer cargo forensic-adb 0.8.1 read_length_little_endian().(&mut stream).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
982
983 stream.read_exactrust-analyzer cargo tokio 1.44.1 io/util/async_read_ext/AsyncReadExt#read_exact().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).rust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().awaitrust-analyzer cargo tokio 1.44.1 io/util/read_exact/impl#[`ReadExact<'_, A>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
984
985 let message = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().)
986 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|s| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("adb error: {}", s))
987 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|_| "adb error was not utf-8".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
988
989 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#(message))
990 } else {
991 if self.removerust-analyzer cargo forensic-adb 0.8.1 impl#[Device]remove().(dest1).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() {
992 warnrust-analyzer cargo log 0.4.27 macros/warn!!("Failed to remove {}", dest1.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
993 }
994 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DeviceErrorrust-analyzer cargo forensic-adb 0.8.1 DeviceError#::Adbrust-analyzer cargo forensic-adb 0.8.1 DeviceError#Adb#("FAIL (unknown)".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()))
995 }
996 }
997
998 pub async fn push_dirrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]push_dir().(&self, source: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, dest_dir: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, mode: u32) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
999 debugrust-analyzer cargo log 0.4.27 macros/debug!!("Pushing {} to {}", source.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), dest_dir.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
1000
1001 let walker = WalkDirrust-analyzer cargo walkdir 2.5.0 WalkDir#::newrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]new().(source).follow_linksrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]follow_links().(false).into_iterrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir][IntoIterator]into_iter().();
1002
1003 for entry in walker {
1004 let entry = entry?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1005 let path = entry.pathrust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]path().();
1006
1007 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().entry.metadatarust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]metadata().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..is_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[Metadata]is_file().() {
1008 continue;
1009 }
1010
1011 let mut file = Filerust-analyzer cargo tokio 1.44.1 fs/file/File#::openrust-analyzer cargo tokio 1.44.1 fs/file/impl#[File]open().(path).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1012
1013 let tail = path
1014 .strip_prefixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]strip_prefix().(source)
1015 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#, e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1016
1017 let dest = append_componentsrust-analyzer cargo forensic-adb 0.8.1 append_components().(dest_dir, tail)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1018 self.pushrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]push().(&mut file, &dest, mode).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1019 }
1020
1021 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
1022 }
1023
1024 pub async fn removerust-analyzer cargo forensic-adb 0.8.1 impl#[Device]remove().(&self, path: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> Resultrust-analyzer cargo forensic-adb 0.8.1 Result#<()> {
1025 debugrust-analyzer cargo log 0.4.27 macros/debug!!("Deleting {}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().());
1026
1027 self.execute_host_shell_command_asrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]execute_host_shell_command_as().(
1028 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("rm -rf {}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().()),
1029 self.enable_run_as_for_pathrust-analyzer cargo forensic-adb 0.8.1 impl#[Device]enable_run_as_for_path().(path),
1030 )
1031 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1032
1033 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
1034 }
1035 }
1036
1037 pub(craterust-analyzer cargo forensic-adb 0.8.1 crate/) fn append_componentsrust-analyzer cargo forensic-adb 0.8.1 append_components().(
1038 base: &UnixPathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#,
1039 tail: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#,
1040 ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<UnixPathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> {
1041 let mut buf = base.to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().();
1042
1043 for component in tail.componentsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]components().() {
1044 if let Componentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Component#::Normalrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Component#Normal#(segment) = component {
1045 let utf8 = segment.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().().ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| {
1046 iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(
1047 iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#,
1048 "Could not represent path segment as UTF-8",
1049 )
1050 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1051 buf.pushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]push().(utf8);
1052 } else {
1053 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(
1054 iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#,
1055 "Unexpected path component".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(),
1056 ));
1057 }
1058 }
1059
1060 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(buf)
1061 }