mime_guess
MIME/media-type guessing from file extensions in Rust
Repository Health
Technical Analysis
mime_guess is a small Rust crate that maps file extensions to MIME types using a static, compiled-in lookup table, so you can determine a plausible Content-Type for a file without inspecting its bytes. It builds on the mime crate for the returned type representation and optionally generates reverse mappings (MIME type back to known extensions) via the rev-mappings feature.
Because the mapping table itself is not considered part of the crate’s stable API — entries are corrected and expanded even in patch releases — mime_guess is meant for best-effort guessing (HTTP responses, file uploads, static file servers) rather than as an authoritative or exhaustive MIME registry.
What You Get
- Extension-to-MIME-type lookup via a static table covering a large set of common file extensions
- Optional reverse lookup (MIME type to extensions) behind the default-on
rev-mappingsfeature - Interop with the
mimecrate so returned values are typedMimeinstances, not raw strings - A version table in the README pinning
mime_guessmajor versions to compatiblemimecrate versions - Case-insensitive extension matching via the
unicasecrate
Common Use Cases
- Setting the
Content-Typeheader for a static file server or HTTP file-download response based on the requested path’s extension - Guessing a MIME type for an uploaded file before further validation or content-based sniffing
- Populating multipart form-data
Content-Typefields when building HTTP clients that send files - Filtering or categorizing files in a CLI/tooling context by their likely MIME type
Under The Hood
Architecture - the crate is a thin, single-purpose lookup layer: src/mime_types.rs holds the generated extension-to-MIME static data, src/impl_bin_search.rs provides a binary-search-based lookup implementation over that table, and src/lib.rs exposes the public from_ext/from_path-style functions on top; a build.rs script assists in generating parts of the table at build time. Tech Stack - pure Rust with two runtime dependencies (mime for the returned type representation, unicase for case-insensitive extension matching) and criterion for benchmarking lookup performance in benches/. Code Quality - the crate includes a benchmark suite (benches/benchmark.rs) validating that binary-search lookups stay fast, and an examples/rev_map.rs demonstrating the reverse-mapping feature, though the project has had no commits in roughly a year and no tagged releases beyond 2.0.5, putting it in low/maintenance-only activity. API Design - the public surface is intentionally minimal (extension in, Mime out, plus an optional reverse lookup), which keeps the learning curve close to zero, but the README explicitly warns that the specific MIME type returned for a given extension is not a stable API guarantee and can change in patch releases — an unusual caveat consumers should account for if they need deterministic output across versions.
Used by 13 apps in this directory
AppFlowy
Productivity · Project Management · Collaboration
The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.
Arroyo
Data Engineering · Analytics
A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.
Cog
AI Development · Devops · Developer Tools
An open-source CLI that packages machine learning models into standard, production-ready Docker containers — no Dockerfile wrangling, no CUDA version hell.
DefGuard
Security · Networking · Authentication
Self-hosted secure remote access that unifies WireGuard VPN, identity management, and connection-level MFA in one open-source platform.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
iii
Developer Tools · Devops
Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.
Joplin
Note Taking
The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.
Lemmy
Community · Social Media
Federated, self-hosted Reddit alternative with full community ownership and no corporate control.
MicroBin
File Storage
A self-contained, encrypted paste bin and file-sharing app in Rust with animal-name URLs, burn-after-read, and one-command Docker deployment.