guess_file

Function guess_file 

Source
pub fn guess_file(file: &File) -> Result<FormatId>
Expand description

Guesses the authoritative format directly from an io/file File.

ยงExamples

use ctb_formats_detection::{guess_file, File, FormatId};

let dir = tempfile::tempdir()?;
let path = dir.path().join("archive.tar.gz");
let gz_header = [0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00];
std::fs::write(&path, gz_header)?;

let file = File::from_filesystem(&path, None)?;
let format = guess_file(&file)?;
assert_eq!(format, FormatId::Gzip);