diff options
author | Sharif Haason <ssh128@scarletmail.rutgers.edu> | 2023-06-13 16:41:34 -0400 |
---|---|---|
committer | Sharif Haason <ssh128@scarletmail.rutgers.edu> | 2023-12-10 13:21:23 -0500 |
commit | 29e3350e690795b19e6abe7a911f48001909470c (patch) | |
tree | 901407e5f8471cfd0435f45aa8f1bc46ea0b6b8a /src | |
parent | 0c192e979bbc56f55cd510583331d8a7cc333f73 (diff) |
Rename `CharTable` to `CharacterTable`
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 32 | ||||
-rw-r--r-- | src/main.rs | 10 |
2 files changed, 21 insertions, 21 deletions
@@ -55,7 +55,7 @@ pub enum ByteCategory { #[derive(Copy, Clone)] #[non_exhaustive] -pub enum CharTable { +pub enum CharacterTable { AsciiOnly, CP437, } @@ -104,10 +104,10 @@ impl Byte { } } - fn as_char(self, char_table: CharTable) -> char { + fn as_char(self, character_table: CharacterTable) -> char { use crate::ByteCategory::*; - match char_table { - CharTable::AsciiOnly => match self.category() { + match character_table { + CharacterTable::AsciiOnly => match self.category() { Null => '⋄', AsciiPrintable => self.0 as char, AsciiWhitespace if self.0 == 0x20 => ' ', @@ -115,7 +115,7 @@ impl Byte { AsciiOther => '•', NonAscii => '×', }, - CharTable::CP437 => CP437[self.0.to_ne_bytes()[0] as usize], + CharacterTable::CP437 => CP437[self.0.to_ne_bytes()[0] as usize], } // match self.category() { // Null => '⋄', @@ -207,7 +207,7 @@ pub struct PrinterBuilder<'a, Writer: Write> { group_size: u8, base: Base, endianness: Endianness, - char_table: CharTable, + character_table: CharacterTable, } impl<'a, Writer: Write> PrinterBuilder<'a, Writer> { @@ -223,7 +223,7 @@ impl<'a, Writer: Write> PrinterBuilder<'a, Writer> { group_size: 1, base: Base::Hexadecimal, endianness: Endianness::Big, - char_table: CharTable::AsciiOnly, + character_table: CharacterTable::AsciiOnly, } } @@ -272,8 +272,8 @@ impl<'a, Writer: Write> PrinterBuilder<'a, Writer> { self } - pub fn char_table(mut self, char_table: CharTable) -> Self { - self.char_table = char_table; + pub fn character_table(mut self, character_table: CharacterTable) -> Self { + self.character_table = character_table; self } @@ -289,7 +289,7 @@ impl<'a, Writer: Write> PrinterBuilder<'a, Writer> { self.group_size, self.base, self.endianness, - self.char_table, + self.character_table, ) } } @@ -333,7 +333,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { group_size: u8, base: Base, endianness: Endianness, - char_table: CharTable, + character_table: CharacterTable, ) -> Printer<'a, Writer> { Printer { idx: 0, @@ -353,7 +353,7 @@ impl<'a, Writer: Write> Printer<'a, Writer> { }) .collect(), byte_char_panel: (0u8..=u8::MAX) - .map(|i| format!("{}", Byte(i).as_char(char_table))) + .map(|i| format!("{}", Byte(i).as_char(character_table))) .collect(), byte_hex_panel_g: (0u8..=u8::MAX).map(|i| format!("{i:02x}")).collect(), squeezer: if use_squeeze { @@ -781,7 +781,7 @@ mod tests { 1, Base::Hexadecimal, Endianness::Big, - CharTable::AsciiOnly, + CharacterTable::AsciiOnly, ); printer.print_all(input).unwrap(); @@ -837,7 +837,7 @@ mod tests { 1, Base::Hexadecimal, Endianness::Big, - CharTable::AsciiOnly, + CharacterTable::AsciiOnly, ); printer.display_offset(0xdeadbeef); @@ -872,7 +872,7 @@ mod tests { 1, Base::Hexadecimal, Endianness::Big, - CharTable::AsciiOnly, + CharacterTable::AsciiOnly, ); printer.print_all(input).unwrap(); @@ -933,7 +933,7 @@ mod tests { 1, Base::Hexadecimal, Endianness::Big, - CharTable::AsciiOnly, + CharacterTable::AsciiOnly, ); printer.print_all(input).unwrap(); diff --git a/src/main.rs b/src/main.rs index 7cee640..8281b55 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ use thiserror::Error as ThisError; use terminal_size::terminal_size; -use hexyl::{Base, BorderStyle, CharTable, Endianness, Input, PrinterBuilder}; +use hexyl::{Base, BorderStyle, CharacterTable, Endianness, Input, PrinterBuilder}; #[cfg(test)] mod tests; @@ -482,13 +482,13 @@ fn run() -> Result<()> { _ => unreachable!(), }; - let char_table = match matches + let character_table = match matches .get_one::<String>("character-table") .unwrap() .as_ref() { - "ascii-only" => CharTable::AsciiOnly, - "codepage-437" => CharTable::CP437, + "ascii-only" => CharacterTable::AsciiOnly, + "codepage-437" => CharacterTable::CP437, _ => unreachable!(), }; @@ -505,7 +505,7 @@ fn run() -> Result<()> { .group_size(group_size) .with_base(base) .endianness(endianness) - .char_table(char_table) + .character_table(character_table) .build(); printer.display_offset(skip_offset + display_offset); printer.print_all(&mut reader).map_err(|e| anyhow!(e))?; |