pub enum FileType {
Show 18 variants
Jpeg,
Png,
Gif,
Webp,
Bmp,
Tiff,
Psd,
Svg,
Pdf,
PostScript,
Zip,
Gzip,
Html,
Pe,
Elf,
MachO,
Script,
Unknown,
}Variants§
Jpeg
Png
Gif
Webp
Bmp
Tiff
Psd
Photoshop PSD or PSB.
Svg
PostScript
Zip
Gzip
Html
Pe
Elf
MachO
Script
Text starting with a #! interpreter line.
Unknown
Implementations§
Source§impl FileType
impl FileType
Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
Examples found in repository?
examples/throughput.rs (line 36)
14fn main() {
15 let scanner = Scanner::builder().build();
16 println!(
17 "{:>9} {:>9} {:>10} type file",
18 "size", "ms/scan", "MB/s"
19 );
20 for path in std::env::args().skip(1) {
21 let data = match std::fs::read(&path) {
22 Ok(data) => data,
23 Err(error) => {
24 eprintln!("{path}: {error}");
25 continue;
26 }
27 };
28 let hints = ScanHints {
29 filename: Some(&path),
30 content_type: None,
31 };
32 let started = Instant::now();
33 let mut runs = 0u32;
34 let mut detected = "";
35 while runs == 0 || started.elapsed() < MIN_RUN {
36 detected = scanner.scan_bytes(&data, hints).detected_type.as_str();
37 runs += 1;
38 }
39 let per_scan = started.elapsed().as_secs_f64() / runs as f64;
40 println!(
41 "{:>9} {:>9.2} {:>10.0} {detected:<10} {path}",
42 data.len(),
43 per_scan * 1e3,
44 data.len() as f64 / per_scan / 1e6,
45 );
46 }
47}Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
The type that Self::as_str spells as name.
pub fn is_executable(self) -> bool
pub fn is_raster_image(self) -> bool
Trait Implementations§
impl Copy for FileType
impl Eq for FileType
impl StructuralPartialEq for FileType
Auto Trait Implementations§
impl Forget for FileType
impl Freeze for FileType
impl Move for FileType
impl RefUnwindSafe for FileType
impl Send for FileType
impl Sync for FileType
impl Unpin for FileType
impl UnsafeUnpin for FileType
impl UnwindSafe for FileType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more