webbluetooth_linux/lib.rs
1//! Linux BLE from pure Rust, with no dependencies.
2//!
3//! Two ways to reach a controller, because Linux offers two:
4//!
5//! * **`bluez`** — the supported path, over `dbus` to `org.bluez`. Pairing,
6//! bonding and agents are the daemon's problem.
7//! * **`hci` + `gatt`** — no daemon at all. ATT over an L2CAP socket for
8//! GATT, a raw HCI socket for scanning.
9//!
10//! Neither binds a C library. D-Bus is a wire protocol over a Unix socket and
11//! is spoken as one; ATT, HCI and L2CAP are kernel sockets reached through
12//! `sys`.
13//!
14//! [`dbus::codec`], [`dbus::value`] and `att` are pure byte manipulation and
15//! build everywhere, so the parts where the bugs live — alignment, truncation,
16//! signature-directed decoding — are unit-tested on any host rather than only
17//! inside a container.
18//!
19//! ## License
20//! MIT — Copyright © 2025 [Eugene Hauptmann](https://github.com/eugenehp)
21
22pub mod att;
23pub mod dbus;
24
25/// LE scanning. The advertising-data parser is portable; only the raw socket
26/// inside it is Linux-only.
27pub mod hci;
28#[cfg(all(target_os = "linux", any(feature = "raw-acl", feature = "raw-sco")))]
29pub mod raw_hci;
30
31// The adapter: BlueZ expressed as the portable model.
32#[cfg(target_os = "linux")]
33// Public so `webbluetooth` can reach it, and not an API anyone else
34// should call: the facade is what a caller holds. Hidden from the docs
35// for the same reason, which also keeps the same 38 adapter methods from
36// being documented six times over.
37#[doc(hidden)]
38pub mod backend;
39// The peripheral-role adapter: a GATT server expressed as the portable model.
40#[cfg(target_os = "linux")]
41pub mod peripheral_backend;
42
43// The same adapter without BlueZ: ATT over an L2CAP socket for GATT, a raw
44// HCI socket for scanning.
45//
46// Compiled whenever the other one is, rather than behind the `linux-hci`
47// feature that selects it. Two adapters that are only ever built one at a
48// time are two adapters that drift, and this one is the one almost nobody
49// builds.
50#[cfg(all(feature = "profiles", feature = "classic-l2cap", target_os = "linux"))]
51pub mod a2dp;
52#[cfg(all(feature = "profiles", feature = "rfcomm", target_os = "linux"))]
53pub mod avrcp;
54#[cfg(target_os = "linux")]
55// Public so `webbluetooth` can reach it, and not an API anyone else
56// should call: the facade is what a caller holds. Hidden from the docs
57// for the same reason, which also keeps the same 38 adapter methods from
58// being documented six times over.
59#[doc(hidden)]
60pub mod backend_hci;
61#[cfg(target_os = "linux")]
62pub mod bluez;
63#[cfg(all(
64 target_os = "linux",
65 feature = "classic",
66 any(feature = "rfcomm", feature = "classic-l2cap")
67))]
68pub mod classic_profile;
69#[cfg(all(feature = "profiles", feature = "rfcomm", target_os = "linux"))]
70pub mod dun;
71#[cfg(target_os = "linux")]
72pub mod gatt;
73#[cfg(all(feature = "profiles", feature = "rfcomm", target_os = "linux"))]
74pub mod hfp;
75#[cfg(all(target_os = "linux", feature = "profiles", feature = "classic-l2cap"))]
76pub mod hid_host;
77#[cfg(target_os = "linux")]
78pub mod l2cap;
79#[cfg(all(target_os = "linux", feature = "classic-l2cap"))]
80pub mod l2cap_classic;
81#[cfg(all(feature = "profiles", feature = "rfcomm", target_os = "linux"))]
82pub mod obex;
83#[cfg(all(feature = "profiles", feature = "classic-l2cap", target_os = "linux"))]
84pub mod pan;
85#[cfg(target_os = "linux")]
86#[cfg(feature = "classic")]
87#[cfg(feature = "rfcomm")]
88#[cfg(feature = "rfcomm")]
89pub mod rfcomm;
90#[cfg(all(feature = "classic", target_os = "linux"))]
91pub mod sdp;
92#[cfg(target_os = "linux")]
93pub mod sys;