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
81
82
83
84
/// A serde helper to deserialize string-based values via FromStr.
///
/// This is specifically required due to a flaw in the Envy crate (which is used for
/// loading configuration from environment variables), when using `#[serde(flatten)]`
/// to split out a 'common' configuration struture which is shared between different
/// main binaries (like a collector and an importer).
///
/// This works for primitive bool and numeric types only. It is not required for strings.
///
/// Example usage:
///
/// ```no_run
/// use serde::{Deserialize, Serialize};
/// #[derive(Serialize, Deserialize)]
/// pub struct CollectorConfig {
/// #[serde(flatten)]
/// pub common: CommonConfig
/// }
///
/// #[derive(Serialize, Deserialize)]
/// pub struct CommonConfig {
/// #[serde(default, deserialize_with="auxon_sdk::plugin_utils::serde::from_str")]
/// pub some_val: Option<bool>
/// }
/// ```
///
/// `envy` crate issue: <https://github.com/softprops/envy/issues/26>
;