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
use serde::Deserialize;
pub mod edges;
pub mod nodes;
#[derive(Clone, Debug)]
pub struct Config {
pub nodes: nodes::Config,
pub edges: edges::Config,
}
impl From<ProtoConfig> for Config {
fn from(proto_cfg: ProtoConfig) -> Config {
Config {
nodes: nodes::Config {
categories: proto_cfg
.nodes
.categories
.into_iter()
.map(|proto_category| proto_category.into())
.collect(),
},
edges: edges::Config {
categories: proto_cfg
.edges
.0
.into_iter()
.map(|proto_category| proto_category.into())
.collect(),
},
}
}
}
#[derive(Clone, Debug)]
pub struct ProtoConfig {
pub nodes: nodes::ProtoConfig,
pub edges: edges::ProtoConfig,
}
impl From<RawConfig> for ProtoConfig {
fn from(raw_cfg: RawConfig) -> ProtoConfig {
ProtoConfig {
nodes: nodes::ProtoConfig::from(raw_cfg.nodes),
edges: edges::ProtoConfig::from(raw_cfg.edges),
}
}
}
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct RawConfig {
pub nodes: nodes::RawConfig,
pub edges: edges::RawConfig,
}