Search

Lib.rs

› Filesystem | Web programming
#media-type #mime

mimee

A simple crate for detection of a file's MIME type by its extension

by Alireza Baloochi

  • Install
  • API reference
  • GitHub repo (alirexaa)

2 unstable releases

0.2.0 Mar 9, 2025
0.1.0 Feb 20, 2025

#2525 in Filesystem

Download history

92 downloads per month

MIT license

45KB
666 lines

Mimee

Mimee is a Rust library that provides a mapping between file extensions and their corresponding MIME types. It allows you to easily determine the MIME type of a file based on its extension.

Features

  • Predefined set of file extensions and their corresponding MIME types.
  • Retrieve the MIME type for a given file path.
  • Supports both forward and backward slashes in file paths.
  • Handles non-ASCII characters in file paths.

Installation

Add this to your Cargo.toml:

[dependencies]
mimee = "0.2.0"

Usage

use mimee::MimeDict;

fn main() {
    let mut mime_dict = MimeDict::new();
    let content_type = mime_dict.get_content_type("example.txt".to_string());
    println!("MIME type: {:?}", content_type);

    // Adding a custom MIME type
    mime_dict.add(".custom".to_string(), "application/x-custom".to_string());
    let custom_content_type = mime_dict.get_content_type("file.custom");
    println!("Custom MIME type: {:?}", custom_content_type);
}

License

This project is licensed under the MIT License

No runtime deps

  • dev rstest 0.25
See also: tree_magic_mini, mime, mediatype, mime2ext, tika-magic, mime_guess, mime-infer, file-format, mime_to_ext, new_mime_guess, mime_guess2

Lib.rs is an unofficial list of Rust/Cargo crates, created by kornelski. It contains data from multiple sources, including heuristics, and manually curated data. Content of this page is not necessarily endorsed by the authors of the crate. This site is not affiliated with nor endorsed by the Rust Project. If something is missing or incorrect, please file a bug.