pub struct HexView<'a> { /* private fields */ }
Expand description
The HexView struct represents the configuration of how to display the data.
Implementations§
source§impl<'a> HexView<'a>
impl<'a> HexView<'a>
sourcepub fn print(&self) -> Result<()>
pub fn print(&self) -> Result<()>
Prints the hextable to stdout. If any colors were given during construction, the specified ranges will be printed in color.
Examples found in repository?
examples/example.rs (line 45)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
fn main() {
let data: Vec<u8> = (0u16..256u16).map(|v| v as u8).collect();
let default_view = HexViewBuilder::new(&data)
.finish();
println!("Default view of all data:\n{}\n\n", default_view);
let ascii_view = HexViewBuilder::new(&data)
.codepage(CODEPAGE_ASCII)
.finish();
println!("Ascii codepage view of all data:\n{}\n\n", ascii_view);
let partial_view = HexViewBuilder::new(&data[10..80])
.address_offset(10)
.finish();
println!("Default view of a subslice:\n{}\n\n", partial_view);
let narrowed_view = HexViewBuilder::new(&data)
.row_width(10)
.finish();
println!("Narrowed view of all data:\n{}\n\n", narrowed_view);
let combined_view = HexViewBuilder::new(&data[10..180])
.address_offset(10)
.codepage(CODEPAGE_1252)
.row_width(14)
.replacement_character(std::char::REPLACEMENT_CHARACTER)
.finish();
println!("Custom view: \n{}\n\n", combined_view);
let color_view = HexViewBuilder::new(&data)
.force_color()
.add_colors(vec![
(hexplay::color::red(), 42..72),
(hexplay::color::yellow_bold(), 10..11),
(hexplay::color::green(), 32..38),
(hexplay::color::blue(), 200..226),
])
.finish();
println!("Coloured view: \n");
color_view.print().unwrap();
println!("\n\n");
}
sourcepub fn new(data: &[u8]) -> HexView<'_>
pub fn new(data: &[u8]) -> HexView<'_>
Constructs a new HexView for the given data without offset and using codepage 850, a row width
of 16 and .
as replacement character.
pub fn fmt<W: WriteColor>(&self, buffer: &mut W) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl<'a> RefUnwindSafe for HexView<'a>
impl<'a> Send for HexView<'a>
impl<'a> Sync for HexView<'a>
impl<'a> Unpin for HexView<'a>
impl<'a> UnwindSafe for HexView<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more