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
//! Transport abstractions for ADB connections.
//!
//! A transport is any type implementing `embedded_io_async::{Read, Write}`.
//! This module ships built-in TCP and USB transports and the [`Splittable`]
//! trait that powers [`Connection::split`](crate::Connection::split) for
//! concurrent read and write tasks on the same connection.
//!
//! # Submodules
//!
//! * [`tcp`] — `TokioTcp` / `SmolTcp` aliases (features `tokio` / `smol`).
//! * `runtime` — the [`Runtime`](runtime::Runtime) trait and its `Tokio`
//! / `Smol` markers, so both runtimes can be compiled in at once.
//! * `nusb` — `UsbTransport` and the [`UsbBackend`] marker `Nusb`
//! (feature `nusb`, also enabled by the `usb` convenience alias).
//! * `rusb` — the same via libusb (feature `rusb`). Both backends can be
//! compiled in at once; pick one per call site through [`UsbBackend`].
//! * [`common`] — [`common::Transport`], a TCP-or-USB enum parameterised
//! over both halves, and [`common::NoUsb`] for builds with no backend.
//! * [`any`] — [`any::AnyTransport`] and [`any::connect`] for URI-based
//! dispatch between `tcp://` and `usb://` (features `tokio` or `smol`).
//! * [`split`] — the [`Splittable`] trait itself.
//! * `tls` — `MaybeTls`, a TCP transport that can start TLS when the
//! device sends `STLS`, and its split halves (feature `tls`).
pub use Splittable;
/// Whether dropping a pending read costs anything.
///
/// A socket read that is dropped leaves its bytes in the kernel buffer,
/// so the next read picks them up. A USB bulk transfer is handed to the
/// device: cancelling it discards whatever the device already wrote
/// into it, which takes the middle out of a packet and leaves every
/// frame boundary after it wrong.
///
/// [`Connection::select_channel`](crate::Connection::select_channel)
/// asks before it lets `interrupt` race a read in flight: a transport
/// that answers `false` gets the interrupt checked between reads
/// instead, which is slower to react but never loses a byte.
/// A USB backend: the way to obtain a USB transport from a
/// [`UsbSelector`](crate::uri::UsbSelector).
///
/// Implemented by the zero-sized markers `nusb::Nusb` and `rusb::Rusb`,
/// and by [`common::NoUsb`] for builds without USB. Choosing a backend
/// is a type argument rather than a feature, so enabling both features
/// compiles and each call site says which one it wants.
/// `R` is the runtime the resulting transport will run its blocking
/// work on. A backend that has none — `nusb` does its own async IO —
/// simply ignores it, while `rusb` uses it for every transfer. Because
/// the runtime comes from the same place as the one dialling TCP, the
/// two cannot drift apart.
/// ADB USB interface class (vendor-specific).
pub const ADB_CLASS: u8 = 0xFF;
/// ADB USB interface subclass.
pub const ADB_SUBCLASS: u8 = 0x42;
/// ADB USB interface protocol.
pub const ADB_PROTOCOL: u8 = 0x01;