Skip to main content

guess_kind

Function guess_kind 

Source
pub fn guess_kind<P: AsRef<Path>>(path: P) -> Result<&'static str, Error>
Expand description

Sniff the file type by reading magic bytes from the start of path.

§Supported formats

Magic bytesOffsetFormat
PK\x03\x04 + mimetypeapplication/epub+zip0 / 30epub
%PDF0pdf
AT&T0djvu
RIFF + WEBP0 / 8webp

WebP files start with "RIFF" and have "WEBP" at bytes 8–11. RIFF alone is not enough because many non-WebP formats (WAV, AVI, …) are also RIFF containers.