multi-mime-guess
A Rust library for determining MIME types based on file extensions.
Overview
This library provides a fast and efficient way to look up MIME types for common file extensions. It uses a pre-generated database built from multiple authoritative sources including:
- jshttp/mime-db npm package
- Apache mime.types
- NGINX mime.types
Features
- Fast lookup - uses a pre-generated perfect hash for O(1) lookup time
- Comprehensive coverage - supports hundreds of file extensions
- Static data - no runtime dependencies, zero allocations
- Cross-platform - works on any platform that supports Rust
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Basic lookup
use lookup;
In your application
Building the database
The MIME type database is generated from authoritative sources and stored in the dbs/ directory. You can regenerate the database by running:
# Fetch and generate databases
The build process automatically generates the perfect hash database using build.rs.
Version bumping
This project uses automated version bumping when MIME databases are updated. The GitHub Actions workflow will:
- Fetch updated MIME databases from all sources
- Detect if any changes were made
- If changes detected, bump the patch version in
Cargo.toml - Create a git commit and push a new tag
See the GitHub Actions workflow for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
MIME type definitions sourced from: