guess_and_report_file

Function guess_and_report_file 

Source
pub fn guess_and_report_file(file: &File) -> Result<DetectionReport>
Expand description

Guesses format candidates and generates a detection report directly from an io/file File.

ยงExamples

use ctb_formats_detection::{guess_and_report_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 report = guess_and_report_file(&file)?;
assert_eq!(report.candidates[0].format_id, Some(FormatId::Gzip));