Function hex_utils::xxd [] [src]

pub fn xxd<T: Read>(data: T, format: Option<Format>) -> XxdLines<T>

Returns xxd iterator over the data configured by format. Passing None to format will use defaults.

Examples

extern crate hex_utils;


let text = "The quick brown fox jumps over the lazy dog";

for (offset, hex, txt) in hex_utils::xxd(text.as_bytes(), None) {
    println!("offset = {:03x} hex = {:60} txt = {}", offset, hex, txt.unwrap());
}
extern crate hex_utils;


let text = "The quick brown fox jumps over the lazy dog";
let format = hex_utils::Format {
    size: 18,
    pack: vec![3,6],
    ascii_none: '-',
    ascii: true,
    gaps:(4,2),
};

let fmt = format.formatter();

for line in hex_utils::xxd(text.as_bytes(), Some(format)) {
    println!("{}", fmt(line));
}