use super::types::{BinaryAlign, BinaryFormat};
impl BinaryFormat {
pub fn new() -> BinaryFormat {
BinaryFormat::default()
}
pub fn prefix(mut self) -> BinaryFormat {
self.prefix = true;
self
}
pub fn no_prefix(mut self) -> BinaryFormat {
self.prefix = false;
self
}
pub fn width(mut self, width: usize) -> BinaryFormat {
self.min_width = width;
self.max_width = width;
self
}
pub fn min_width(mut self, min_width: usize) -> BinaryFormat {
self.min_width = min_width;
self
}
pub fn max_width(mut self, max_width: usize) -> BinaryFormat {
self.max_width = max_width;
self
}
pub fn width_option(self, width: Option<usize>) -> BinaryFormat {
self.min_width_option(width).max_width_option(width)
}
pub fn min_width_option(mut self, width: Option<usize>) -> BinaryFormat {
match width {
Some(width) => {
self.min_width = width;
self
}
None => self,
}
}
pub fn max_width_option(mut self, width: Option<usize>) -> BinaryFormat {
match width {
Some(width) => {
self.max_width = width;
self
}
None => self,
}
}
pub fn left_align(mut self) -> BinaryFormat {
self.align = BinaryAlign::Left;
self
}
pub fn right_align(mut self) -> BinaryFormat {
self.align = BinaryAlign::Right;
self
}
pub fn fill_char(mut self, fill_char: char) -> BinaryFormat {
self.fill_char = fill_char;
self
}
}