FileType

Enum FileType 

Source
#[non_exhaustive]
pub enum FileType {
Show 39 variants Zip, Rar5, Rar, Tar, Lzma, Xz, Zst, Png, Jpg, _7z, Opus, Vorbis, Mp3, Webp, Flac, Matroska, Wasm, Class, Tasty, Mach, Elf, Wav, Avi, Aiff, Tiff, Sqlite3, Ico, Dalvik, Pdf, DosMzExecutable, DosZmExecutable, Xcf, Gif, Bmp, Iso, Gpg, ArmoredGpg, Swf, Swc,
}
Expand description

All file types that bindet is able to detect, some of them are just different versions of the same format or very similar.

bindet is able to do both, refined detection, which it tries to detect FileType precisely, and general detection, which it tries to do a weaker FileType detection (note: in its current state, it is only doing the precise detection).

A more general categorization is enumerated by FileRootType.

§Supported file types

  • Zip
  • Rar5
  • Rar
  • Tar
  • Lzma
  • Xz
  • Zst
  • Png
  • Jpg
  • _7z
  • Opus
  • Vorbis
  • Mp3
  • Webp
  • Flac
  • Matroska
  • Wasm
  • Class
  • Tasty
  • Mach
  • Elf
  • Wav
  • Avi
  • Aiff
  • Tiff
  • Sqlite3
  • Ico
  • Dalvik
  • Pdf
  • DosMzExecutable
  • DosZmExecutable
  • Xcf
  • Gif
  • Bmp
  • Iso
  • Gpg
  • ArmoredGpg
  • Swf
  • Swc

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Zip

Zip file format, this includes:

  • jar
  • docx/xlsx/pptx
  • Apk
  • Aar
  • odt/ods/odp
§

Rar5

§

Rar

§

Tar

Tar archive (only uncompressed).

Compressed tar archives are first archived using tar, then compressed, which means that in order to detect compressed tar files we need to decompress them first, which is not viable for this library, and is not part of its goal.

§

Lzma

§

Xz

§

Zst

§

Png

§

Jpg

§

_7z

§

Opus

Opus Ogg

§

Vorbis

Vorbis Ogg

§

Mp3

§

Webp

§

Flac

§

Matroska

All Matroska media containers:

  • mkv
  • mka
  • mks
  • mk3d
  • webm
§

Wasm

WebAssembly

§

Class

Java class

§

Tasty

Scala Tasty

§

Mach

Mach-O (untested)

§

Elf

Executable and Linkable Format

  • .so
  • *nix executable
§

Wav

Waveform Audio File Format

§

Avi

§

Aiff

Audio Interchange File Format

  • aiff
  • aif
  • aifc
  • snd
  • iff
§

Tiff

Tagged Image File Format

  • Tiff
  • Tif
§

Sqlite3

SQLite 3 Database

§

Ico

§

Dalvik

Dalvik (untested)

§

Pdf

PDF Document

§

DosMzExecutable

DOS MZ Executable

  • .exe
  • .dll
§

DosZmExecutable

DOS MZ Executable

  • .exe
§

Xcf

Gimp XCF

§

Gif

Gif

§

Bmp

Bitmap

§

Iso

Optical Disc Image

§

Gpg

§

ArmoredGpg

§

Swf

Adobe Small Web Format

§

Swc

Implementations§

Source§

impl FileType

Source

pub const fn variants() -> [FileType; 39]

Source

pub fn root(&self) -> FileRootType

Gets the FileRootType of this FileType

Trait Implementations§

Source§

impl Clone for FileType

Source§

fn clone(&self) -> FileType

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FileType

Source§

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

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

impl FileTypeDescription for FileType

Source§

fn smallest_block_size( &self, relative_position: &RelativePosition, ) -> Option<usize>

Smallest block size to start with and try to detect this file Read more
Source§

fn ideal_block_size( relative_position: &RelativePosition, ) -> Option<(usize, Vec<FileType>)>

Returns the ideal block size to start with and the filetypes that has an starting block size. Read more
Source§

fn ideal_block_size_of_variants( relative_position: &RelativePosition, variants: &[FileType], ) -> Option<(usize, Vec<FileType>)>

Returns the ideal block size to start with and the filetypes that has an starting block size. Read more
Source§

fn maximum_block_size( relative_position: &RelativePosition, ) -> Option<(usize, Vec<FileType>)>

Returns the maximum block size to try when ideal block size is not enough, along with the filetypes that has large block sizes. Read more
Source§

fn maximum_block_size_of_variants( relative_position: &RelativePosition, variants: &[FileType], ) -> Option<(usize, Vec<FileType>)>

Returns the maximum block size to try when ideal block size is not enough, along with the filetypes that has large block sizes. Read more
Source§

fn largest_block_size( &self, relative_position: &RelativePosition, ) -> Option<usize>

Largest block size to start with and try to detect this file Read more
Source§

impl FileTypeMatcher for FileType

Source§

fn test( &self, relative_position: &RelativePosition, step: &Step, bytes: &[u8], ) -> TestResult

Tests if the FileType magic number can be found in the bytes slice.
Source§

impl From<FileType> for FileRootType

Source§

fn from(file_type: FileType) -> Self

Converts to this type from the input type.
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: &FileType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for FileType

Source§

impl Eq for FileType

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.