Skip to main content

FileType

Enum FileType 

Source
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

§

Pdf

§

PostScript

§

Zip

§

Gzip

§

Html

§

Pe

§

Elf

§

MachO

§

Script

Text starting with a #! interpreter line.

§

Unknown

Implementations§

Source§

impl FileType

Source

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}
Source

pub fn from_name(name: &str) -> Option<Self>

The type that Self::as_str spells as name.

Source

pub fn is_executable(self) -> bool

Source

pub fn is_raster_image(self) -> bool

Trait Implementations§

Source§

impl Clone for FileType

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FileType

Source§

impl Debug for FileType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for FileType

Source§

impl Hash for FileType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for FileType

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for FileType

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for FileType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.