etop_format/binary_format/
builder.rs1use super::types::{BinaryAlign, BinaryFormat};
2
3impl BinaryFormat {
4 pub fn new() -> BinaryFormat {
6 BinaryFormat::default()
7 }
8
9 pub fn prefix(mut self) -> BinaryFormat {
13 self.prefix = true;
14 self
15 }
16
17 pub fn no_prefix(mut self) -> BinaryFormat {
19 self.prefix = false;
20 self
21 }
22
23 pub fn width(mut self, width: usize) -> BinaryFormat {
27 self.min_width = width;
28 self.max_width = width;
29 self
30 }
31
32 pub fn min_width(mut self, min_width: usize) -> BinaryFormat {
34 self.min_width = min_width;
35 self
36 }
37
38 pub fn max_width(mut self, max_width: usize) -> BinaryFormat {
40 self.max_width = max_width;
41 self
42 }
43
44 pub fn width_option(self, width: Option<usize>) -> BinaryFormat {
46 self.min_width_option(width).max_width_option(width)
47 }
48
49 pub fn min_width_option(mut self, width: Option<usize>) -> BinaryFormat {
51 match width {
52 Some(width) => {
53 self.min_width = width;
54 self
55 }
56 None => self,
57 }
58 }
59
60 pub fn max_width_option(mut self, width: Option<usize>) -> BinaryFormat {
62 match width {
63 Some(width) => {
64 self.max_width = width;
65 self
66 }
67 None => self,
68 }
69 }
70
71 pub fn left_align(mut self) -> BinaryFormat {
75 self.align = BinaryAlign::Left;
76 self
77 }
78
79 pub fn right_align(mut self) -> BinaryFormat {
81 self.align = BinaryAlign::Right;
82 self
83 }
84
85 pub fn fill_char(mut self, fill_char: char) -> BinaryFormat {
89 self.fill_char = fill_char;
90 self
91 }
92}