pub struct Hexxdump { /* private fields */ }Expand description
A hex dumper with a given configuration
Implementations§
Source§impl Hexxdump
impl Hexxdump
Sourcepub const fn with_config(config: Config) -> Self
pub const fn with_config(config: Config) -> Self
Sourcepub fn hexdump<B: AsRef<[u8]>>(&self, bytes: B)
pub fn hexdump<B: AsRef<[u8]>>(&self, bytes: B)
Writes the hex dump of bytes to stdout
Equivalent to calling hexdump_to(std::io::stdout(), bytes)
Examples found in repository?
examples/demo.rs (line 12)
1fn main() {
2 let bytes = (0..=255).collect::<Vec<u8>>();
3
4 println!("Default:");
5 hexxdump::hexdump(&bytes);
6 println!("");
7
8 println!("Control pictures:");
9 hexxdump::config::DEFAULT
10 .use_control_pictures(true)
11 .into_hexxdump()
12 .hexdump(&bytes);
13 println!("");
14
15 println!("No address:");
16 hexxdump::config::DEFAULT
17 .show_address(false)
18 .into_hexxdump()
19 .hexdump(&bytes);
20 println!("");
21
22 println!("Extended address:");
23 hexxdump::config::DEFAULT
24 .address_width(8)
25 .into_hexxdump()
26 .hexdump(&bytes);
27 println!("");
28
29 println!("Character dump:");
30 hexxdump::config::DEFAULT
31 .bytes_per_row(64)
32 .show_hex_values(false)
33 .substitute_character('␦')
34 .into_hexxdump()
35 .hexdump(&bytes);
36 println!("");
37
38 println!("Hex value dump:");
39 hexxdump::config::DEFAULT
40 .show_characters(false)
41 .bytes_per_row(32)
42 .into_hexxdump()
43 .hexdump(&bytes);
44 println!("");
45}Sourcepub fn hexdump_to<W: Write, B: AsRef<[u8]>>(
&self,
output: W,
bytes: B,
) -> Result<usize>
pub fn hexdump_to<W: Write, B: AsRef<[u8]>>( &self, output: W, bytes: B, ) -> Result<usize>
Writes the hex dump of bytes to the given byte sink, output
Sourcepub fn get_hexdump<B: AsRef<[u8]>>(&self, bytes: B) -> String
pub fn get_hexdump<B: AsRef<[u8]>>(&self, bytes: B) -> String
Returns the hex dump of bytes as a String
Sourcepub fn byte_to_char(&self, byte: u8) -> char
pub fn byte_to_char(&self, byte: u8) -> char
Utility function to convert a given byte to its char representation
Sourcepub fn get_hex_values<B: AsRef<[u8]>>(&self, bytes: B) -> String
pub fn get_hex_values<B: AsRef<[u8]>>(&self, bytes: B) -> String
Utility function to convert the given bytes into a string of hex values
Returns the middle column of what would be a single-row hex dump
Sourcepub fn get_characters<B: AsRef<[u8]>>(&self, bytes: B) -> String
pub fn get_characters<B: AsRef<[u8]>>(&self, bytes: B) -> String
Utility function to convert the given bytes into a string of characters
Returns the the right column of what would be a single-row hex dump
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hexxdump
impl RefUnwindSafe for Hexxdump
impl Send for Hexxdump
impl Sync for Hexxdump
impl Unpin for Hexxdump
impl UnwindSafe for Hexxdump
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