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
//! Type-safe keys for settings storage.
use PhantomData;
/// Register a type-safe settings key.
///
/// This macro is the primary way to create settings keys. It associates
/// a string key name with a value type at compile time.
///
/// **Important:** The key name must be globally unique across the entire application.
/// Using the same key name for different settings will cause conflicts.
///
/// # Example
/// ```rust
/// use bitwarden_state::register_setting_key;
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
/// struct AppConfig {
/// theme: String,
/// auto_save: bool,
/// }
///
/// register_setting_key!(pub const CONFIG: AppConfig = "app_config");
/// ```
/// Type-safe key for settings storage.
///
/// Associates a string key name with a value type at compile time,
/// preventing type mismatches while maintaining ergonomic usage.
///
/// Use the [`register_setting_key!`](crate::register_setting_key) macro to create keys.
///
/// # Example
/// ```rust
/// use bitwarden_state::register_setting_key;
/// use serde::{Deserialize, Serialize};
///
/// #[derive(Serialize, Deserialize)]
/// struct AppConfig {
/// theme: String,
/// auto_save: bool,
/// }
///
/// register_setting_key!(pub const CONFIG: AppConfig = "app_config");
/// ```