etop_format/string_format/
builder.rs1use super::types::{StringAlign, StringFormat};
2
3impl StringFormat {
4 pub fn new() -> StringFormat {
6 StringFormat::default()
7 }
8
9 pub fn width(mut self, width: usize) -> StringFormat {
13 self.min_width = width;
14 self.max_width = width;
15 self
16 }
17
18 pub fn min_width(mut self, min_width: usize) -> StringFormat {
20 self.min_width = min_width;
21 self
22 }
23
24 pub fn max_width(mut self, max_width: usize) -> StringFormat {
26 self.max_width = max_width;
27 self
28 }
29
30 pub fn width_option(self, width: Option<usize>) -> StringFormat {
32 self.min_width_option(width).max_width_option(width)
33 }
34
35 pub fn min_width_option(mut self, width: Option<usize>) -> StringFormat {
37 match width {
38 Some(width) => {
39 self.min_width = width;
40 self
41 }
42 None => self,
43 }
44 }
45
46 pub fn max_width_option(mut self, width: Option<usize>) -> StringFormat {
48 match width {
49 Some(width) => {
50 self.max_width = width;
51 self
52 }
53 None => self,
54 }
55 }
56
57 pub fn left_align(mut self) -> StringFormat {
61 self.align = StringAlign::Left;
62 self
63 }
64
65 pub fn right_align(mut self) -> StringFormat {
67 self.align = StringAlign::Right;
68 self
69 }
70
71 pub fn fill_char(mut self, fill_char: char) -> StringFormat {
75 self.fill_char = fill_char;
76 self
77 }
78}