summaryrefslogtreecommitdiffstats
path: root/src/element/mod.rs
blob: 3425bed5988bf2d18050470e82cd4a74d70db0b5 (plain)
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
use std::collections::HashMap;

#[derive(Debug, PartialEq, serde::Deserialize)]
#[serde(untagged)]
pub enum ConfigElement<'a> {
    Null,
    Bool(bool),
    I8(i8),
    I16(i16),
    I32(i32),
    I64(i64),
    U8(u8),
    U16(u16),
    U32(u32),
    U64(u64),
    F32(f32),
    F64(f64),
    Str(&'a str),
    List(Vec<ConfigElement<'a>>),
    Map(HashMap<&'a str, ConfigElement<'a>>),
}

pub trait AsConfigElement {
    type Error: std::error::Error;

    fn as_config_element<'a>(&'a self) -> Result<ConfigElement<'a>, Self::Error>;
}

#[cfg(feature = "json")]
mod json;

#[cfg(feature = "toml")]
mod toml;