pub fn format_value_as_hex(value: &Value) -> StringExpand description
Format a Value as a hexadecimal string for JSON output
Converts different Value types to their hexadecimal string representation suitable for inclusion in JSON output. Byte arrays are converted directly, while other types are first converted to their byte representation.
§Arguments
value- The Value to format as hexadecimal
§Returns
A lowercase hexadecimal string without separators or prefixes
§Examples
use libmagic_rs::output::json::format_value_as_hex;
use libmagic_rs::parser::ast::Value;
let bytes_value = Value::Bytes(vec![0x7f, 0x45, 0x4c, 0x46]);
assert_eq!(format_value_as_hex(&bytes_value), "7f454c46");
let string_value = Value::String("PNG".to_string());
assert_eq!(format_value_as_hex(&string_value), "504e47");
let uint_value = Value::Uint(0x1234);
assert_eq!(format_value_as_hex(&uint_value), "3412000000000000"); // Little-endian u64