use crate::colors;
use super::decoder::try_decode_value;
pub fn print_output(name: &str, return_type: &str, bytes: &[u8]) {
println!(
"\n{}{}:{} {}{}{}",
colors::CYAN,
name,
colors::RESET,
colors::DIM,
return_type,
colors::RESET
);
match try_decode_value(return_type, bytes) {
Some(value) => {
println!(" {}", value);
}
None => {
eprintln!(
" {}[Note]{} Type '{}' not directly displayable",
colors::YELLOW,
colors::RESET,
return_type
);
let preview_len = bytes.len().min(64);
println!(
" {}[{} bytes]{} {:?}{}",
colors::DIM,
bytes.len(),
colors::RESET,
&bytes[..preview_len],
if bytes.len() > 64 { "..." } else { "" }
);
}
}
}