28 lines
591 B
Rust
28 lines
591 B
Rust
#[cfg(feature = "debug-trace")]
|
|
macro_rules! trace {
|
|
($($arg:tt)*) => {
|
|
eprintln!("[TRACE] {}", format!($($arg)*));
|
|
};
|
|
}
|
|
|
|
#[cfg(not(feature = "debug-trace"))]
|
|
macro_rules! trace {
|
|
($($arg:tt)*) => {};
|
|
}
|
|
|
|
pub(crate) use trace;
|
|
|
|
#[allow(dead_code)]
|
|
pub fn hex_preview(data: &[u8], len: usize) -> String {
|
|
let preview: Vec<String> = data
|
|
.iter()
|
|
.take(len)
|
|
.map(|b| format!("{:02x}", b))
|
|
.collect();
|
|
if data.len() > len {
|
|
format!("{}... ({} bytes)", preview.join(""), data.len())
|
|
} else {
|
|
preview.join("")
|
|
}
|
|
}
|