Skip to main content

classify_fallback

Function classify_fallback 

Source
pub fn classify_fallback(buffer: &[u8]) -> &'static str
Expand description

Classify a buffer using the minimal text/data fallback described in the module doc.

Returns one of "empty", "ASCII text", "UTF-8 Unicode text", or "data". This is intentionally infallible – there is no input for which classification can fail, so the caller never needs to handle an error path here (matching the evaluator’s graceful-degradation discipline: a fallback that can itself fail would defeat its purpose).

§Examples

use libmagic_rs::output::ascmagic::classify_fallback;

assert_eq!(classify_fallback(b""), "empty");
assert_eq!(classify_fallback(b"hello world\n"), "ASCII text");
assert_eq!(classify_fallback(&[0x00, 0x01, 0x02, 0xff]), "data");