Crate hexplay [−] [src]
This crate provides a way to Display a byte slice as it is commonly done in a hex-editor.
The configuration of the visualization are stored in the HexView, struct, which can be easily constructed using the HexViewBuilder.
Examples
Usage is very simple, just build a HexView
and use it for formatting:
use hexplay::HexViewBuilder; // The buffer we want to display let data : Vec<u8> = (0u8..200u8).collect(); // Build a new HexView using the provider builder let view = HexViewBuilder::new(&data[40..72]) .address_offset(40) .row_width(16) .finish(); println!("{}", view);
This will result in the following output:
00000020 28 29 2A 2B 2C 2D 2E 2F | ()*+,-./ |
00000030 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F | 0123456789:;<=>? |
00000040 40 41 42 43 44 45 46 47 | @ABCDEFG |
Color
You can add color to the hextable by specifying a color::Spec and a range in the hextable to color, using HexViewBuilder's add_colors method.
NB: overlapping color ranges have unspecified behavior (not unsafe though, of course)
use hexplay::HexViewBuilder; let data : Vec<u8> = (0u8..200u8).collect(); let view = HexViewBuilder::new(&data[40..72]) .address_offset(40) .row_width(16) .add_colors(vec![ (hexplay::color::red(), 6..15), (hexplay::color::blue(), 21..26), (hexplay::color::yellow_bold(), 15..21), (hexplay::color::green(), 0..6), ]) .finish(); // this will print to stdout view.print().unwrap();
Modules
color |
Provides helpers for generating colors for use in HexViewBuilder printing,
as well as some reexports of the underlying color crate, |
Structs
HexView |
The HexView struct represents the configuration of how to display the data. |
HexViewBuilder |
A builder for the HexView struct. |
Constants
CODEPAGE_0850 |
The mapping for code page 850 |
CODEPAGE_1252 |
The mapping for code page 1252 |
CODEPAGE_ASCII |
The mapping for ASCII |