Function infer::get_from_path [−][src]
pub fn get_from_path<P: AsRef<Path>>(path: P) -> Result<Option<Type>>
Returns the file type of the file given a path.
Errors
Returns an error if we fail to read the path.
Examples
let kind = infer::get_from_path("testdata/sample.jpg") .expect("file read successfully") .expect("file type is known"); assert_eq!(kind.mime_type(), "image/jpeg"); assert_eq!(kind.extension(), "jpg");