Expand description
A hex dumper which calls a closure to allow the application to choose how to output the dump.
§Example: Dumping a struct
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);
});§Example: Dumping a struct with addresses
Sometimes it may be useful to include the real addresses in dumped buffers. This can be accomplished by adding a base offset to the configuration context.
use dbgtools_hexdump::{Config, hexdump};
struct MyStruct {
eight: u8,
sixteen: u16,
thirtytwo: u32
}
let data = MyStruct { eight: 8, sixteen: 16, thirtytwo: 32 };
hexdump(Config {
offs: &data as *const _ as usize,
..Default::default()
}, &data, |offs, hex, ascii| {
println!("{:08x} {} {}", offs, hex, ascii);
});Structs§
- Config
- Hex dumper configuration context.
Functions§
- asbuf
- Return a
Sizedobject as a byte slice. 😬 - hexdump
- Generate a hex dump of a
Sizedobject and call a closure to process each hex dump line. - hexdump_
buf - Generate a hex dump of a byte buffer (
&[u8]) and call a closure to process each hex dump line.