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
//! Picking up a Bluetooth session the system interrupted.
//!
//! Only iOS relaunches a terminated process to finish Bluetooth work, but the
//! types are portable: every backend reports what it recovered the same way,
//! and the five that never recover anything report `None`.
use crate;
use crateResult;
/// Opt in to Bluetooth state preservation and restoration.
///
/// The system preserves a manager's peripherals and scan across process death
/// and hands them back through `willRestoreState:` on the next launch.
///
/// # This only does something on iOS
///
/// `CBCentralManagerOptionRestoreIdentifierKey` is declared on macOS too, and
/// passing it is harmless there, but **only iOS relaunches a terminated process
/// to finish Bluetooth work** — and only one that declares the
/// `bluetooth-central` (or `bluetooth-peripheral`) background mode in its
/// `Info.plist`. On every other platform this is inert: no callback arrives and
/// `Bluetooth::restored_session` stays `None`.
///
/// # Grants do not survive
///
/// A Web Bluetooth grant is per-session, and the system does not preserve which
/// services a user allowed. So a restored session's allowlist is whatever you
/// declare here, up front — restored devices get exactly these services and
/// nothing else.
/// What a backend found waiting for it when the system brought it back.
///
/// Written once here rather than once per backend: the shape is the same
/// everywhere because it is a description of an interrupted scan, not of a
/// platform.