lune_utils/fmt/value/
config.rs

1/**
2    Configuration for formatting values.
3*/
4#[derive(Debug, Clone, Copy)]
5pub struct ValueFormatConfig {
6    pub(super) max_depth: usize,
7    pub(super) colors_enabled: bool,
8}
9
10impl ValueFormatConfig {
11    /**
12        Creates a new config with default values.
13    */
14    #[must_use]
15    pub const fn new() -> Self {
16        Self {
17            max_depth: 3,
18            colors_enabled: false,
19        }
20    }
21
22    /**
23        Sets the maximum depth to which tables will be formatted.
24    */
25    #[must_use]
26    pub const fn with_max_depth(self, max_depth: usize) -> Self {
27        Self { max_depth, ..self }
28    }
29
30    /**
31        Sets whether colors should be enabled.
32
33        Colors are disabled by default.
34    */
35    #[must_use]
36    pub const fn with_colors_enabled(self, colors_enabled: bool) -> Self {
37        Self {
38            colors_enabled,
39            ..self
40        }
41    }
42}
43
44impl Default for ValueFormatConfig {
45    fn default() -> Self {
46        Self::new()
47    }
48}