Curated list of file extensions commonly associated with binary files.
The crate ships one immutable list covering archives, images, audio, video, office
documents, executables, fonts, RAW camera formats, and similar. Read the
BINARY_EXTENSIONS static or call all(). Both give the same
&'static [&'static str].
[dependencies]
binary-extensions = "0.1.1"use binary_extensions::BINARY_EXTENSIONS;
assert!(BINARY_EXTENSIONS.contains(&"png"));
assert!(!BINARY_EXTENSIONS.contains(&"txt"));Entries are bare lowercase ASCII tokens such as "png", without a leading dot.
Strip the dot and lowercase an extension before checking membership, otherwise
names like IMAGE.PNG are missed. The one exception is "DS_Store", the macOS
Finder metadata file, which keeps its casing and matches as is.
The list holds 262 unique ASCII entries in hand-curated order. The order is part
of the contract and is stored verbatim. Every entry is lowercase except
"DS_Store".
Classification by extension is a heuristic. A few entries, for example rtf,
m3u, and slk, are text-encoded formats kept for compatibility, so a listed
extension can still name a file of plain text.
The crate is #![no_std], has no dependencies, and is
#![forbid(unsafe_code)]. MSRV is 1.56, edition 2021, and the tests run on that
release.
Licensed under the MIT license.