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
/**
    Configuration for formatting values.
*/
#[derive(Debug, Clone, Copy)]
pub struct ValueFormatConfig {
    pub(super) max_depth: usize,
    pub(super) colors_enabled: bool,
}

impl ValueFormatConfig {
    /**
        Creates a new config with default values.
    */
    #[must_use]
    pub const fn new() -> Self {
        Self {
            max_depth: 3,
            colors_enabled: false,
        }
    }

    /**
        Sets the maximum depth to which tables will be formatted.
    */
    #[must_use]
    pub const fn with_max_depth(self, max_depth: usize) -> Self {
        Self { max_depth, ..self }
    }

    /**
        Sets whether colors should be enabled.

        Colors are disabled by default.
    */
    #[must_use]
    pub const fn with_colors_enabled(self, colors_enabled: bool) -> Self {
        Self {
            colors_enabled,
            ..self
        }
    }
}

impl Default for ValueFormatConfig {
    fn default() -> Self {
        Self::new()
    }
}