summaryrefslogtreecommitdiff
path: root/src/config.rs
blob: 1fba27ff0abf5d762dfc0ff769c20d0960ca1bfe (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
35
36
37
38
use serde_derive::{Deserialize, Serialize};

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Server {
    pub listen: String,
    #[serde(default = "default_false")]
    pub no_ack_extension: bool,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Service {
    pub name: String,
    pub addr: String, // host:port
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Client {
    pub addr: String,
    #[serde(default = "default_false")]
    pub no_ack: bool,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Root {
    pub server: Option<Server>,
    pub client: Option<Client>,
    pub service: Vec<Service>,
    #[serde(default = "default_true")]
    pub allow_help: bool,
}

fn default_true() -> bool {
    true
}

fn default_false() -> bool {
    false
}