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 16 apps in this directory
OpenViking
AI Development · AI Memory · Databases
An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.
Readur
Bookmarks Archiving · File Storage · Knowledge Management
A self-hosted document management system that OCRs, indexes, and makes every PDF, scan, and Office file instantly searchable.
Silex
Design Tools · No Code Platforms
Free, open-source visual website builder that exports clean HTML/CSS — no lock-in, no subscription, host anywhere
Spacedrive
Collaboration · File Storage
One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.
Temps
Analytics · Devops · Monitoring
A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.
TensorZero
Ab Testing Experimentation · AI Development · Monitoring
TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.
Vibe Kanban
AI Agents · AI Code Assistants · Project Management
A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.