Function run

Source
pub fn run(config: Config) -> Result<(), String>
Expand description

Performs the appropriate operation, depending on the provided Config.

Depending on the value of reverse, this function will perform either a hex dump or reverse hex dump.

§Examples

let config = hxx::Config {
    cols: 16,
    byte_groups: 2,
    reverse: false,
    input: Box::new(std::io::stdin()),
    output: Box::new(std::io::stdout()),
};

// Performs a hex dump
if let Err(err) = hxx::run(config) {
    eprintln!("Error: {err}");
    std::process::exit(1);
}
let config = hxx::Config {
    cols: 16,
    byte_groups: 2,
    reverse: true,
    input: Box::new(std::io::stdin()),
    output: Box::new(std::io::stdout()),
};

// Performs a reverse hex dump
if let Err(err) = hxx::run(config) {
    eprintln!("Error: {err}");
    std::process::exit(1);
}

§Error

This function returns an error if the underlying hex_dump or reverse_hex_dump function fails. The specific error conditions are documented in the respective functions.