1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! # `file_type`
//!
//! [](https://codecov.io/gh/theseus-rs/file-type)
//! [](https://bencher.dev/perf/theseus-rs-file-type)
//! [](https://github.com/theseus-rs/file-type#license)
//! [](https://semver.org/spec/v2.0.0.html)
//!
//! ## Getting Started
//!
//! A file type. The file type is determined by examining the file or bytes against known file
//! signatures and file extensions.
//!
//! Signature, extension and media type data are provided by:
//! * [Apache HTTPD](https://github.com/apache/httpd/blob/trunk/docs/conf/mime.types)
//! * [IANA](https://www.iana.org/assignments/media-types/media-types.xml)
//! * [Linguist](https://github.com/github-linguist/linguist/blob/main/lib/linguist/languages.yml)
//! * [The National Archives PRONOM](https://www.nationalarchives.gov.uk/pronom/)
//! * [Wikidata](https://www.wikidata.org/wiki/Wikidata:WikiProject_Informatics/Structures/File_formats/List)
//!
//! # Example
//!
//! Detect a file type from bytes:
//! ```
//! use file_type::FileType;
//!
//! let file_type = FileType::from_bytes(b"\xCA\xFE\xBA\xBE");
//! assert_eq!(file_type.name(), "Java class file");
//! assert_eq!(file_type.extensions(), vec!["class"]);
//! ```
//!
//! Retrieve a file type from an extension:
//! ```
//! use file_type::FileType;
//!
//! let file_types = FileType::from_extension("png");
//! let file_type = file_types.first().expect("file format");
//! assert_eq!(file_type.media_types(), vec!["image/png"]);
//! ```
//!
//! Retrieve a file type from a media type:
//! ```
//! use file_type::FileType;
//!
//! let file_types = FileType::from_media_type("image/png");
//! let file_type = file_types.first().expect("file format");
//! assert_eq!(file_type.extensions(), vec!["png"]);
//! ```
//!
//! ## Feature flags
//!
//! | Name | Description | Default? |
//! |------------|----------------------------------------------------------------------------------------------------------------------------|----------|
//! | `httpd` | Enables [Apache HTTPD](https://github.com/apache/httpd/blob/trunk/docs/conf/mime.types) file types | No |
//! | `iana` | Enables [IANA](https://www.iana.org/assignments/media-types/media-types.xml) file types | No |
//! | `linguist` | Enables [Linguist](https://github.com/github-linguist/linguist/blob/main/lib/linguist/languages.yml) file types | No |
//! | `pronom` | Enables [PRONOM](https://www.nationalarchives.gov.uk/PRONOM) file types | No |
//! | `std` | Enables support for the Rust standard library | Yes |
//! | `wikidata` | Enables [Wikidata](https://www.wikidata.org/wiki/Wikidata:WikiProject_Informatics/Structures/File_formats/List) file types | Yes |
//!
//! ## Supported File Types
//!
//! [List of supported file types](https://github.com/theseus-rs/file-type/blob/main/FILETYPES.md)
//!
//! ## Safety
//!
//! This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% safe Rust.
extern crate alloc;
extern crate core;
pub use ;
pub use FileType;