1#![forbid(unsafe_code, missing_debug_implementations, missing_docs)]
2#![cfg_attr(test, deny(warnings))]
3
4extern crate failure;
16
17use failure::Error;
18
19pub fn fmt(input: &[u8]) -> Result<String, Error> {
21 let string: String =
22 input.iter().map(|byte| format!("{:02x}", byte)).collect();
23
24 if string.len() > 8 {
25 let (head, tail) = string.split_at(6);
26 let cut_off = tail.len() - 2;
27 let (_, tail) = tail.split_at(cut_off);
28 Ok(format!("{}..{}", head, tail))
29 } else {
30 Ok(string)
31 }
32}