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
55
56
57
58
59
60
61
62
/*
    Appellation: config <mod>
    Contrib: FL03 <jo3mccain@icloud.com>
*/
use super::Features;

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Config {
    pub biased: bool,
    pub name: String,
    pub shape: Features,
}

impl Config {
    pub fn new(name: impl ToString, shape: Features) -> Self {
        Self {
            biased: false,
            name: name.to_string(),
            shape,
        }
    }

    pub fn is_biased(&self) -> bool {
        self.biased
    }

    pub fn biased(self) -> Self {
        Self {
            biased: true,
            ..self
        }
    }

    pub fn unbiased(self) -> Self {
        Self {
            biased: false,
            ..self
        }
    }

    pub fn with_name(self, name: impl ToString) -> Self {
        Self {
            name: name.to_string(),
            ..self
        }
    }

    pub fn with_shape(self, shape: Features) -> Self {
        Self { shape, ..self }
    }
}

impl Default for Config {
    fn default() -> Self {
        Self {
            biased: false,
            name: String::new(),
            shape: Features::default(),
        }
    }
}