Macro smart_config::Serde 
source · macro_rules! Serde { (*) => { ... }; ($($expecting:tt),+ $(,)?) => { ... }; }
Expand description
Constructor of Serde types / instances.
The macro accepts a comma-separated list of expected basic types from the following set: bool, int,
float, str, array, object. As a shortcut, Serde![*] signals to accept any input.
§Examples
#[derive(Debug)]
struct ComplexType {
    // ...
}
impl Serialize for ComplexType {
    // Complex serialization logic...
}
impl<'de> Deserialize<'de> for ComplexType {
    // Complex deserialization logic...
}
#[derive(DescribeConfig, DeserializeConfig)]
struct TestConfig {
    /// Will try to deserialize any integer, string or object delegating
    /// to the `Deserialize` impl. Will error on other inputs (e.g., arrays).
    #[config(with = Serde![int, str, object])]
    complex_param: ComplexType,
    #[config(with = Serde![*])]
    anything: serde_json::Value,
}