wayle_bluetooth/lib.rs
1//! Bluetooth device management via BlueZ D-Bus.
2//!
3//! # Quick Start
4//!
5//! ```rust,no_run
6//! use wayle_bluetooth::BluetoothService;
7//!
8//! # async fn example() -> Result<(), wayle_bluetooth::Error> {
9//! let bt = BluetoothService::new().await?;
10//!
11//! // Check adapter state
12//! if bt.available.get() {
13//! println!("Bluetooth available, powered: {}", bt.enabled.get());
14//! }
15//!
16//! // List paired devices
17//! for device in bt.devices.get().iter() {
18//! let name = device.name.get().unwrap_or_default();
19//! println!("{}: {}", name, device.address.get());
20//! }
21//! # Ok(())
22//! # }
23//! ```
24//!
25//! # Watching for Changes
26//!
27//! ```rust,no_run
28//! use wayle_bluetooth::BluetoothService;
29//! use futures::StreamExt;
30//!
31//! # async fn example() -> Result<(), wayle_bluetooth::Error> {
32//! # let bt = BluetoothService::new().await?;
33//! // React to new devices
34//! let mut stream = bt.devices.watch();
35//! while let Some(devices) = stream.next().await {
36//! println!("Device count: {}", devices.len());
37//! }
38//! # Ok(())
39//! # }
40//! ```
41//!
42//! # Discovery and Pairing
43//!
44//! ```rust,no_run
45//! # use wayle_bluetooth::BluetoothService;
46//! # use std::time::Duration;
47//! # async fn example() -> Result<(), wayle_bluetooth::Error> {
48//! # let bt = BluetoothService::new().await?;
49//! // Scan for 30 seconds
50//! bt.start_timed_discovery(Duration::from_secs(30)).await?;
51//!
52//! // Connect to a device
53//! for device in bt.devices.get().iter() {
54//! if device.name.get().as_deref() == Some("My Headphones") {
55//! device.connect().await?;
56//! }
57//! }
58//! # Ok(())
59//! # }
60//! ```
61//!
62//! # Reactive Properties
63//!
64//! All fields are [`Property<T>`](wayle_core::Property):
65//! - `.get()` - Current value snapshot
66//! - `.watch()` - Stream yielding on changes
67//!
68//! # Service Fields
69//!
70//! | Field | Type | Description |
71//! |-------|------|-------------|
72//! | `adapters` | `Vec<Arc<Adapter>>` | All Bluetooth adapters |
73//! | `primary_adapter` | `Option<Arc<Adapter>>` | Active adapter for operations |
74//! | `devices` | `Vec<Arc<Device>>` | All discovered devices |
75//! | `available` | `bool` | Whether any adapter is present |
76//! | `enabled` | `bool` | Whether any adapter is powered |
77//! | `connected` | `Vec<String>` | Addresses of connected devices |
78//! | `pairing_request` | `Option<PairingRequest>` | Pending pairing request |
79//!
80//! # Control Methods
81//!
82//! - [`enable()`](BluetoothService::enable) / [`disable()`](BluetoothService::disable) - Power adapter
83//! - [`start_discovery()`](BluetoothService::start_discovery) / [`stop_discovery()`](BluetoothService::stop_discovery) - Scan
84//! - [`start_timed_discovery()`](BluetoothService::start_timed_discovery) - Scan with timeout
85//!
86//! Device-level: `connect()`, `disconnect()`, `pair()`, `forget()`
87
88mod agent;
89/// Bluetooth domain models for adapters and devices.
90pub mod core;
91mod discovery;
92mod error;
93mod monitoring;
94mod proxy;
95mod service;
96/// BlueZ type definitions for adapter/device properties.
97pub mod types;
98
99pub use error::Error;
100pub use service::BluetoothService;
101
102#[doc = include_str!("../README.md")]
103#[cfg(doctest)]
104pub struct ReadmeDocTests;