etop_format/bool_format/
builder.rs

1use super::types::{BoolAlign, BoolFormat};
2
3impl BoolFormat {
4    /// create new number format
5    pub fn new() -> BoolFormat {
6        BoolFormat::default()
7    }
8
9    // width
10
11    /// set width
12    pub fn width(mut self, width: usize) -> BoolFormat {
13        self.min_width = width;
14        self.max_width = width;
15        self
16    }
17
18    /// set min_width
19    pub fn min_width(mut self, min_width: usize) -> BoolFormat {
20        self.min_width = min_width;
21        self
22    }
23
24    /// set max_width
25    pub fn max_width(mut self, max_width: usize) -> BoolFormat {
26        self.max_width = max_width;
27        self
28    }
29
30    /// set width
31    pub fn width_option(self, width: Option<usize>) -> BoolFormat {
32        self.min_width_option(width).max_width_option(width)
33    }
34
35    /// set min_width
36    pub fn min_width_option(mut self, width: Option<usize>) -> BoolFormat {
37        match width {
38            Some(width) => {
39                self.min_width = width;
40                self
41            }
42            None => self,
43        }
44    }
45
46    /// set max_width
47    pub fn max_width_option(mut self, width: Option<usize>) -> BoolFormat {
48        match width {
49            Some(width) => {
50                self.max_width = width;
51                self
52            }
53            None => self,
54        }
55    }
56
57    // align
58
59    /// left align
60    pub fn left_align(mut self) -> BoolFormat {
61        self.align = BoolAlign::Left;
62        self
63    }
64
65    /// right align
66    pub fn right_align(mut self) -> BoolFormat {
67        self.align = BoolAlign::Right;
68        self
69    }
70
71    // fill char
72
73    /// add fill char
74    pub fn fill_char(mut self, fill_char: char) -> BoolFormat {
75        self.fill_char = fill_char;
76        self
77    }
78
79    // value formats
80
81    /// true format
82    pub fn true_text(mut self, true_text: String) -> BoolFormat {
83        self.true_text = true_text;
84        self
85    }
86
87    /// false format
88    pub fn false_text(mut self, false_text: String) -> BoolFormat {
89        self.false_text = false_text;
90        self
91    }
92}