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
//! Typed notification deserialization helpers.
//!
//! Available when the `serde` feature is enabled. Eliminates manual JSON
//! parsing boilerplate in client modules.
//!
//! # Example
//!
//! ```ignore
//! #[derive(serde::Deserialize)]
//! struct WhichKeyPayload { active: bool, prefix: String }
//!
//! fn on_notification(&mut self, data: &str) {
//! if let Some(payload) = parse_notification::<WhichKeyPayload>(data) {
//! self.active = payload.active;
//! }
//! }
//! ```
/// Deserialize a notification JSON string into a typed struct.
///
/// Returns `None` if deserialization fails (lenient: modules silently
/// ignore notifications they don't understand).
/// Deserialize and extract a specific field from a notification JSON object.
///
/// Returns `None` if the JSON is invalid, the field is missing, or the field
/// value doesn't match type `T`.