use crate::Hexxdump;
pub const DEFAULT: Config = Config {
bytes_per_row: 16,
address_width: 4,
show_address: true,
show_hex_values: true,
show_characters: true,
use_control_pictures: false,
substitute_character: '.',
};
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Config {
pub(super) bytes_per_row: usize,
pub(super) address_width: usize,
pub(super) show_address: bool,
pub(super) show_hex_values: bool,
pub(super) show_characters: bool,
pub(super) use_control_pictures: bool,
pub(super) substitute_character: char,
}
impl Config {
pub const fn new() -> Self { DEFAULT }
pub const fn into_hexxdump(self) -> Hexxdump { Hexxdump::with_config(self) }
pub const fn bytes_per_row(mut self, bytes_per_row: usize) -> Self {
self.bytes_per_row = bytes_per_row;
self
}
pub const fn address_width(mut self, address_width: usize) -> Self {
self.address_width = address_width;
self
}
pub const fn show_address(mut self, show: bool) -> Self {
self.show_address = show;
self
}
pub const fn show_hex_values(mut self, show: bool) -> Self {
self.show_hex_values = show;
self
}
pub const fn show_characters(mut self, show: bool) -> Self {
self.show_characters = show;
self
}
pub const fn use_control_pictures(mut self, use_cp: bool) -> Self {
self.use_control_pictures = use_cp;
self
}
pub const fn substitute_character(mut self, substitute_character: char) -> Self {
self.substitute_character = substitute_character;
self
}
}
impl Default for Config {
fn default() -> Self { Self::new() }
}