Expand description
§minimime
A minimal MIME type detection library for Rust, ported from the Ruby minimime gem.
This library provides fast MIME type detection based on file extensions and content types, using embedded database files for efficient lookups without external dependencies.
§Features
- Fast lookups: Uses embedded hash maps for average O(1) MIME type detection
- No external dependencies: Database files are embedded at compile time
- Case insensitive: Handles file extensions in any case
- Binary detection: Identifies binary vs text file types
- Thread safe: Safe for concurrent use across multiple threads
§Quick Start
use minimime::{lookup_by_filename, lookup_by_extension, lookup_by_content_type};
// Look up by filename
if let Some(info) = lookup_by_filename("document.pdf") {
println!("MIME type: {}", info.content_type); // "application/pdf"
println!("Is binary: {}", info.is_binary()); // true
}
// Look up by extension
if let Some(info) = lookup_by_extension("json") {
println!("MIME type: {}", info.content_type); // "application/json"
}
// Look up by content type
if let Some(info) = lookup_by_content_type("text/css") {
println!("Extension: {}", info.extension); // "css"
}§Supported File Types
This library supports hundreds of file extensions and MIME types, including:
- Web formats (HTML, CSS, JS, JSON, XML)
- Images (PNG, JPEG, GIF, SVG, WebP)
- Documents (PDF, DOC, XLS, PPT)
- Archives (ZIP, TAR, GZ)
- Media files (MP3, MP4, AVI, MOV)
- And many more…
Structs§
- Db
- Internal database for MIME type lookups.
- Info
- MIME type information including extension, content type, and encoding.
Functions§
- lookup_
by_ content_ type - Looks up MIME information by content type.
- lookup_
by_ extension - Looks up MIME information by file extension.
- lookup_
by_ filename - Looks up MIME information by filename.