Hexxdump

Struct Hexxdump 

Source
pub struct Hexxdump { /* private fields */ }
Expand description

A hex dumper with a given configuration

Implementations§

Source§

impl Hexxdump

Source

pub const fn with_config(config: Config) -> Self

Creates a Hexxdump using the given Config

Source

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}
Source

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

Source

pub fn get_hexdump<B: AsRef<[u8]>>(&self, bytes: B) -> String

Returns the hex dump of bytes as a String

Source

pub fn byte_to_char(&self, byte: u8) -> char

Utility function to convert a given byte to its char representation

Source

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

Source

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§

Source§

impl Clone for Hexxdump

Source§

fn clone(&self) -> Hexxdump

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Hexxdump

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.