Skip to main content

hexdump_to_sink

Function hexdump_to_sink 

Source
pub fn hexdump_to_sink(bytes: &[u8], sink: &mut dyn LogSink, columns: usize)
Expand description

Writes a classic hex dump to a LogSink.

Each line is formatted as:

0x00000000: 01 02 03 ... |....|
  • bytes: input data to render.
  • sink: output destination.
  • columns: number of bytes per line. If 0, defaults to 16.

This function is best-effort: it ignores formatting errors because the underlying sink is infallible by contract.

Examples found in repository?
examples/hexdump_demo.rs (line 14)
11fn main() {
12    let data = [0u8, 1, 2, 3, 0xaa, 0xbb, 0xcc, 0xdd];
13    let mut sink = StdoutSink;
14    hexdump_to_sink(&data, &mut sink, 8);
15}