Enum file_format::FileFormat[][src]

pub enum FileFormat {
Show 118 variants Odp, Ods, Odg, Odt, Vdi, Epub, Skp, Deb, InDesignDocument, Sqlite3, Html, ICalendar, Mxf, Apng, Jpeg, JpegXl, Ktx, Ktx2, Matroska, VCard, Fits, OggAudio, OggVideo, QuickTime, Wmv, GbcRom, Lzop, Orf, Aiff, Mobi, Avi, Avif, GbRom, GbaRom, Heif, Lnk, Mp4, Msi, N64Rom, NdsRom, Png, Rar, Tar, Wave, WebM, WebP, Xcf, Ar, Blender, Jp2, M4a, M4v, ThirdGpp, ThirdGpp2, Gif, SevenZip, Xml, Xz, Amr, Eot, Iso, OpenType, Pdf, Rtf, TrueType, Ape, AppleIconImage, Bpg, Cab, ChromeExtension, Cineon, Dex, Dicom, Dpx, Elf, Flac, Flif, Flv, Gltf, Ico, JavaClass, Lrzip, Lz4, Lzip, Midi, Mpc, Mpeg, NesRom, OpenExr, Pcap, Pcapng, PhotoshopDocument, Rpm, Shapefile, Snd, Tiff, WavPack, WebAssembly, Wmf, Woff, Woff2, Xar, Zip, Zstandard, Bzip2, JpegXr, Mp3, Swf, Aac, Ac3, AppleDiskImage, Bmp, Compress, Exe, Gzip, M2ts, Text, Binary,
}
Expand description

Represents a file format.

Variants

Odp

OpenDocument Presentation (ODP)

Ods

OpenDocument SpreadSheet (ODS)

Odg

OpenDocument Graphics (ODG)

Odt

OpenDocument Text (ODT)

Vdi

VirtualBox Virtual Disk Image (VDI)

Epub

Electronic Publication (EPUB)

Skp

SketchUp Document

Deb

Debian package

InDesignDocument

Adobe InDesign document

Sqlite3

SQLite 3 Database

Html

HyperText Markup Language (HTML)

ICalendar

iCalendar

Mxf

Material Exchange Format (MXF)

Apng

Animated Portable Network Graphics (APNG)

Jpeg

Joint Photographic Experts Group (JPEG)

JpegXl

JPEG XL

Ktx

Khronos TeXture (KTX)

Ktx2

Khronos TeXture 2 (KTX2)

Matroska

Matroska Multimedia Container

VCard

vCard

Fits

Flexible Image Transport System (FITS)

OggAudio

Ogg audio

OggVideo

Ogg video

QuickTime

QuickTime Movie

Wmv

Windows Media Video (WMV)

GbcRom

Game Boy Color ROM

Lzop

Lzop

Orf

Olympus Raw Format (ORF)

Aiff

Audio Interchange File Format (AIFF)

Mobi

Mobipocket

Avi

Audio Video Interleave (AVI)

Avif

AV1 Image File Format (AVIF)

GbRom

Game Boy ROM

GbaRom

Game Boy Advance ROM

Heif

High Efficiency Image File Format (HEIF)

Lnk

Windows shortcut

Mp4

MPEG-4 Part 14 (MP4)

Msi

Windows Installer

N64Rom

Nintendo 64 ROM

NdsRom

Nintendo DS ROM

Png

Portable Network Graphics (PNG)

Rar

Roshal ARchive (RAR)

Tar

Tape archive (tar)

Wave

Waveform Audio (WAVE)

WebM

WebM

WebP

WebP

Xcf

eXperimental Computing Facility (XCF)

Ar

Archiver

Blender

Blender 3D Data

Jp2

JPEG 2000

M4a

Audio-only MPEG-4

M4v

M4V

ThirdGpp

3rd Generation Partnership Project (3GPP)

ThirdGpp2

3rd Generation Partnership Project 2 (3GPP2)

Gif

Graphics Interchange Format (GIF)

SevenZip

7-Zip

Xml

Extensible Markup Language (XML)

Xz

XZ

Amr

Adaptive Multi-Rate (AMR)

Eot

Embedded OpenType (EOT)

Iso

ISO image

OpenType

OpenType

Pdf

Portable Document Format (PDF)

Rtf

Rich Text Format (RTF)

TrueType

TrueType

Ape

Monkey’s Audio

AppleIconImage

Apple Icon Image

Bpg

Better Portable Graphics (BPG)

Cab

Cabinet (CAB)

ChromeExtension

Google Chrome Extension

Cineon

Cineon Image

Dex

Dalvik Executable

Dicom

Digital Imaging and Communications in Medicine (DICOM)

Dpx

Digital Picture Exchange (DPX)

Elf

Executable and Linkable Format (ELF)

Flac

Free Lossless Audio Codec (FLAC)

Flif

Free Lossless Image Format (FLIF)

Flv

Flash Video (FLV)

Gltf

GL Transmission Format (glTF) binary

Ico

ICO

JavaClass

Java class

Lrzip

Long Range ZIP (lrzip)

Lz4

LZ4

Lzip

Lzip

Midi

Musical Instrument Digital Interface (MIDI)

Mpc

Musepack (MPC)

Mpeg

MPEG-1 video

NesRom

Nintendo Entertainment System ROM

OpenExr

OpenEXR

Pcap

Libpcap

Pcapng

Pcap-NG Packet Capture

PhotoshopDocument

Adobe Photoshop document

Rpm

Red Hat Package Manager (RPM) package

Shapefile

Shapefile

Snd

SouND (SND)

Tiff

Tag Image File Format (TIFF)

WavPack

WavPack

WebAssembly

WebAssembly binary

Wmf

Windows Metafile (WMF)

Woff

Web Open Font Format (WOFF)

Woff2

Web Open Font Format 2 (WOFF2)

Xar

eXtensible ARchive format (XAR)

Zip

ZIP

Zstandard

Zstandard

Bzip2

Bzip2

JpegXr

JPEG extended range (JPEG XR)

Mp3

MPEG-1/2 Audio Layer III (MP3)

Swf

Small Web Format (SWF)

Aac

Advanced Audio Coding (AAC)

Ac3

Audio Codec 3 (AC-3)

AppleDiskImage

Apple Disk Image

Bmp

Windows Bitmap (BMP)

Compress

Unix compress

Exe

Windows Executable

Gzip

Gzip

M2ts

MPEG-2 Transport Stream (M2TS)

Text

UTF-8 encoded text

Binary

Arbitrary binary data

Implementations

Determines file format from bytes.

If the signature of the file is not recognized, it will try to detect if the file is an UTF-8 encoded text and if so return FileFormat::Text. Otherwise, it will return FileFormat::Binary which corresponds to arbitrary binary data.

Examples

Detects from the first bytes of a PNG file:

use file_format::FileFormat;

let format = FileFormat::from_bytes(b"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A");
assert_eq!(format, FileFormat::Png);
assert_eq!(format.media_type(), "image/png");
assert_eq!(format.preferred_extension(), "png");

Detects from an UTF-8 text:

use file_format::FileFormat;

let format = FileFormat::from_bytes("岁月不留人".as_bytes());
assert_eq!(format, FileFormat::Text);
assert_eq!(format.media_type(), "text/plain");
assert_eq!(format.preferred_extension(), "txt");

Detects from a zeroed buffer:

use file_format::FileFormat;

let format = FileFormat::from_bytes(&[0; 1000]);
assert_eq!(format, FileFormat::Binary);
assert_eq!(format.media_type(), "application/octet-stream");
assert_eq!(format.preferred_extension(), "bin");

Determines file format from an extension.

Examples

Detects from an extension:

use file_format::FileFormat;

let format = FileFormat::from_extension("ttf");
assert_eq!(format, Some(FileFormat::TrueType));

Detects from an unknown extension:

use file_format::FileFormat;

let format = FileFormat::from_extension("foobar");
assert_eq!(format, None);

Determines file format from a media type.

Examples

Detects from a media type:

use file_format::FileFormat;

let format = FileFormat::from_media_type("video/mp4");
assert_eq!(format, Some(FileFormat::Mp4));

Detects from an unknown media type:

use file_format::FileFormat;

let format = FileFormat::from_media_type("foo/bar");
assert_eq!(format, None);

Determines file format from a file.

Examples

Basic usage:

use file_format::FileFormat;

let format = FileFormat::from_file("Cargo.toml")?;
assert_eq!(format, FileFormat::Text);

Returns the media type (formerly known as MIME type) of the file format.

Examples

Basic usage:

use file_format::FileFormat;

let format = FileFormat::Zstandard;
assert_eq!(format.media_type(), "application/zstd");

Returns the extensions list of the file format.

Examples

Basic usage:

use file_format::FileFormat;

let format = FileFormat::Midi;
assert_eq!(format.extensions(), vec!["mid", "midi"]);

Returns the preferred extension of the file format.

Examples

Basic usage:

use file_format::FileFormat;

let format = FileFormat::Wmv;
assert_eq!(format.preferred_extension(), "wmv");

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.