1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//! Low-level ADB (Android Debug Bridge) wire-protocol library.
//!
//! Talks to a device directly over TCP or USB — no `adbd` fork/exec,
//! no `adb` binary, no platform-tools dependency.
//!
//! The core protocol layer is `no_std + alloc`. Any runtime feature
//! (`tokio`, `smol`, `nusb`, `rusb`) implicitly enables `std` — the
//! split Reader/Writer pair and USB backends rely on std sync
//! primitives. For pure `no_std + alloc` builds, use the crate with
//! `default-features = false` and bring your own `embedded_io_async`
//! transport.
//!
//! For a C ABI, see the companion crate `libadb-ffi`.
//!
//! # Feature flags
//!
//! | Flag | Enables |
//! |---------|----------------------------------------------------------------------------|
//! | `tokio` | TCP transport over `tokio::net::TcpStream` (default) |
//! | `smol` | TCP transport over `smol::net::TcpStream`; may be combined with `tokio` |
//! | `nusb` | USB transport via `nusb` (pure-Rust); may be combined with `rusb` |
//! | `rusb` | USB transport via `rusb` (libusb); may be combined with `nusb` |
//! | `usb` | Convenience alias enabling the default USB backend (`nusb`) |
//! | `split` | [`split`] Reader/Writer pair with no bundled runtime; pulls in `std`. Implied by every feature above |
//!
//! # Quick start
//!
//! ```ignore
//! use libadb::shell::v2;
//! use libadb::{Connection, Feature, TokioTcp};
//!
//! let tcp = tokio::net::TcpStream::connect("127.0.0.1:5555").await?;
//! let transport = TokioTcp::new(tcp);
//!
//! // `auth` is a user-supplied `libadb::auth::Authenticator` —
//! // typically an RSA signer reading `~/.android/adbkey`. A complete
//! // `AdbKeyAuth` using the `rsa` crate lives in `examples/`.
//! let mut conn = Connection::<_>::connect(transport, auth, &[Feature::ShellV2]).await?;
//!
//! let mut rx = [0u8; 64 * 1024];
//! let out = v2::exec(&mut conn, "getprop ro.product.model", &mut rx).await?;
//! println!("{}", core::str::from_utf8(&out.stdout)?);
//! ```
//!
//! # Memory budget
//!
//! Every connection is opened with a [`ConnectionConfig`] that bounds
//! what the library may allocate:
//!
//! * `max_payload` — advertised to the device in CNXN, so it caps the
//! size of any single inbound packet (and hence the receive buffer);
//! * `initial_ack_bytes` — delayed-ACK credit granted per channel;
//! * `max_rx_per_channel` — fuse on data buffered for a channel nobody
//! is reading.
//!
//! [`ConnectionConfig::new`] reproduces `adb`'s desktop behaviour (1 MiB
//! packets, 32 MiB credit, unbounded buffering).
//! [`ConnectionConfig::embedded`] fits a microcontroller:
//!
//! ```ignore
//! let conn = Connection::<_>::connect_with_config(
//! transport, auth, &[Feature::ShellV2], ConnectionConfig::embedded(),
//! ).await?;
//! ```
//!
//! On a microcontroller-sized heap the default config is unusable: one
//! 64 KiB WRTE can exhaust it, because the packet has to be buffered
//! whole. `embedded()` caps packets at 8 KiB, and adbd honours the
//! advertised limit.
//!
//! # Services
//!
//! * [`shell::v1`] — legacy `shell:` (interleaved stdout/stderr, no exit code)
//! * [`shell::v2`] — framed stdout/stderr/exit, optional PTY
//! * [`exec`] — binary-clean `exec:` (no PTY, no exit code)
//! * [`cmd`] — `abb_exec` / `abb` / `shell:cmd` fallback chain
//! * [`abb`] — Android Binder Bridge (Android 10+)
//! * [`logcat`] — parsed binary logcat stream
//! * [`sync`] — file transfer (`STAT` / `LIST` / `SEND` / `RECV`, v1 + v2)
//! * [`track_app`] — streaming debuggable/profileable process list
//!
//! # Transports
//!
//! `TokioTcp`, `SmolTcp`, `transport::nusb::UsbTransport`,
//! `transport::rusb::UsbTransport`, or any user type implementing
//! `embedded_io_async::{Read, Write}` plus [`Splittable`]. For concurrent
//! read and write tasks on the same connection, see
//! [`Connection::split`] and the resulting `Reader` / `Writer` pair.
//!
//! # Status
//!
//! Pre-1.0. Public API is subject to semver-breaking changes before 1.0.
extern crate alloc;
extern crate std;
// Structural: expose private `base::*` submodules as top-level modules.
pub use ;
// Core types used in every non-trivial caller.
pub use ;
pub use ;
pub use ;
pub use Splittable;
pub use ;
pub use TokioTcp;
pub use SmolTcp;
pub use ;
/// Common vocabulary for `use libadb::prelude::*;`.