[Crate hunt] rle hex dump

I'm working on some network code that's sending a lot of mostly-zero raw Ethernet packets. On the receiver I'm looking for something that can dump &[u8] as something akin to:

[0x00*500 0x01 0x02 0x03*8]

(The the exact format is not important; just its ability to compress repeating values in some manner).

Anyone know if there's a hex dump crate that has this ability already?

You might be better off writing it yourself, even if a library exists. The algorithm can be very simple (just remember the most recent byte and the count so far, then print it as soon as a different byte is seen), and by having control of the code you can tweak it for readability for your particular application.

2 Likes

I was bored :slight_smile:

8 Likes