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
29// The adapter: BlueZ expressed as the portable model.
30#[cfg(target_os = "linux")]
31// Public so `webbluetooth` can reach it, and not an API anyone else
32// should call: the facade is what a caller holds. Hidden from the docs
33// for the same reason, which also keeps the same 38 adapter methods from
34// being documented six times over.
35#[doc(hidden)]
36pub mod backend;
37// The peripheral-role adapter: a GATT server expressed as the portable model.
38#[cfg(target_os = "linux")]
39pub mod peripheral_backend;
40
41// The same adapter without BlueZ: ATT over an L2CAP socket for GATT, a raw
42// HCI socket for scanning.
43//
44// Compiled whenever the other one is, rather than behind the `linux-hci`
45// feature that selects it. Two adapters that are only ever built one at a
46// time are two adapters that drift, and this one is the one almost nobody
47// builds.
48#[cfg(target_os = "linux")]
49// Public so `webbluetooth` can reach it, and not an API anyone else
50// should call: the facade is what a caller holds. Hidden from the docs
51// for the same reason, which also keeps the same 38 adapter methods from
52// being documented six times over.
53#[doc(hidden)]
54pub mod backend_hci;
55#[cfg(target_os = "linux")]
56pub mod bluez;
57#[cfg(target_os = "linux")]
58pub mod gatt;
59#[cfg(target_os = "linux")]
60pub mod l2cap;
61#[cfg(target_os = "linux")]
62pub mod sys;