[WIP] esyn

github crates.io docs.rs build status

Rusty Config File Parser.

Example

```rust use esyn::{Esyn, EsynDe};

fn main() { let config = r#" fn main() { let a = Config { name: "hi", map: Map::Down, window: Window { borderless: true, topmost: false, }, opt: Some(56), };

a.window.color = Color {
    bg:13,
    fg:-12,
};

let other = Other {
    _u8: 1,
    _string: "abcd",
    name: "hi",
    _vec_u8: [1,2,3,4],
};

other._u8 = 123;

let num = Num {
    _i32: -32,
    _i128: -12345678909876543210123456789i128,
    _i16: 16i16,
    _string: "abc",
};

}

fn main2() { let other = Other { u8: 2, _string: "abcdefg", name: "hi", _vecu8: [1,2,3,4], }; } "#;

let mut esyn = Esyn::new(&config).unwrap();
esyn.update::<Config>("main").unwrap();
esyn.update::<Other>("main").unwrap();
esyn.update::<Num>("main").unwrap();
esyn.update::<Other>("main2").unwrap();

assert_eq!(
    &esyn.get::<Config>("main", "a").unwrap(),
    &Config {
        name: "hi".to_string(),
        map: Map::Down,
        window: Window {
            borderless: true,
            topmost: false,
            color: Color { bg: 13, fg: -12 },
        },
        opt: Some(56),
    }
);

assert_eq!(
    &esyn.get::<Other>("main", "other").unwrap(),
    &Other {
        _u8: 123,
        _string: "abcd".to_string(),
        name: "hi".to_string(),
        _vec_u8: [1, 2, 3, 4].to_vec(),
    }
);

assert_eq!(
    &esyn.get::<Other>("main2", "other").unwrap(),
    &Other {
        _u8: 2,
        _string: "abcdefg".to_string(),
        name: "hi".to_string(),
        _vec_u8: [1, 2, 3, 4].to_vec(),
    }
);

assert_eq!(
    &esyn.get::<Num>("main", "num").unwrap(),
    &Num {
        _i32: -32,
        _string: "abc".to_string(),
        _i16: 16,
        _i128: -12345678909876543210123456789,
    }
);

}

[derive(Debug, PartialEq, Default, EsynDe)]

struct Other { u8: u8, _string: String, name: String, _vecu8: Vec, }

[derive(Debug, PartialEq, Default, EsynDe)]

struct Config { name: String, opt: Option, window: Window, map: Map, }

[derive(PartialEq, EsynDe)]

enum Map { Up, Down, Any(String), }

impl std::fmt::Debug for Map { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { Self::Up => write!(f, "Map::Up"), Self::Down => write!(f, "Map::Down",), Self::Any(v) => write!(f, "Map::Any({:?})", v), } } }

impl Default for Map { fn default() -> Self { Map::Up } }

[derive(Debug, PartialEq, Default, EsynDe)]

struct Window { borderless: bool, topmost: bool, color: Color, }

[derive(Debug, PartialEq, Default, EsynDe)]

struct Color { bg: u8, fg: i8, }

[derive(Debug, PartialEq, Default, EsynDe)]

struct Num { _i32: i32, _i128: i128, _i16: i16, _string: String, }

```

For more examples take a look on tests

Supported Types

```rust u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize f32 f64 bool char String

Vec Option HashMap BTreeMap

Option Option Option

Struct Enum Tuple

fastimageresize::FilterType

?Box

```

TODO

to_string() Debug -> ? Default -> ?