[][src]Function tree_magic::match_u8

pub fn match_u8(mimetype: &str, bytes: &[u8]) -> bool

Checks if the given bytestream matches the given MIME type.

Returns true or false if it matches or not. If the given MIME type is not known, the function will always return false. If mimetype is an alias of a known MIME, the file will be checked agains that MIME.

Examples

// Load a GIF file
let input: &[u8] = include_bytes!("../tests/image/gif");

// Check if the MIME and the file are a match
let result = tree_magic::match_u8("image/gif", input);
assert_eq!(result, true);