; ``` ### Check for specific type class ```rust let buf = [0xFF, 0xD8, 0xFF, 0xAA]; assert!(infer::is_image(&buf)); ``` ### Adds a custom file type matcher Here we actually need to use the `Infer` struct to be able to declare custom matchers. ```rust # #[cfg(feature = "alloc")] # fn run() { fn custom_matcher(buf: &[u8]) -> bool { return buf.len() >= 3 && buf[0] == 0x10 && buf[1] == 0x11 && buf[2] == 0x12; } let mut info = infer::Infer::new(); info.add("custom/foo", "foo", custom_matcher); let buf = [0x10, 0x11, 0x12, 0x13]; let kind = info.get(&buf).unwrap(); assert_eq!(kind.mime_type(), "custom/foo"); assert_eq!(kind.extension(), "foo"); # } ```