bindet (binary file type detection)
Fast file type detection. Read more here: documentation
Example:
use ;
use BufReader;
use ErrorKind;
use bindet;
use FileType;
use FileTypeMatch;
use FileTypeMatches;
Fast file type detection. Read more here: documentation
use std::fs::{OpenOptions};
use std::io::BufReader;
use std::io::ErrorKind;
use bindet;
use bindet::types::FileType;
use bindet::FileTypeMatch;
use bindet::FileTypeMatches;
fn example() {
let file = OpenOptions::new().read(true).open("files/test.tar").unwrap();
let buf = BufReader::new(file);
let detect = bindet::detect(buf).map_err(|e| e.kind());
let expected: Result<Option<FileTypeMatches>, ErrorKind> = Ok(Some(FileTypeMatches::new(
vec![FileType::Tar],
vec![FileTypeMatch::new(FileType::Tar, true)]
)));
assert_eq!(detect, expected);
}