dbgtools_hexdump

Function hexdump

Source
pub fn hexdump<C, T, F>(cfg: C, buf: &T, f: F)
where C: Borrow<Config>, T: Sized, F: Fn(usize, &str, &str),
Expand description

Generate a hex dump of a Sized object and call a closure to process each hex dump line.

use dbgtools_hexdump::{Config, hexdump};

struct MyStruct {
  eight: u8,
  sixteen: u16,
  thirtytwo: u32
}

let data = MyStruct { eight: 8, sixteen: 16, thirtytwo: 32 };

hexdump(Config::default(), &data, |offs, hex, ascii| {
  println!("{:08x} {} {}", offs, hex, ascii);
});