3 releases
| 0.1.2 | Jun 15, 2025 |
|---|---|
| 0.1.1 | Jan 2, 2025 |
| 0.1.0 | Jan 1, 2025 |
#675 in Images
160 downloads per month
Used in 3 crates
21KB
315 lines
Suika MIME: A Toy MIME Type Utility
Important: This is a personal toy project, developed as an experiment and learning exercise.
As a toy project, its future development is uncertain. It may or may not receive future updates, maintenance, or bug fixes. Please do not use it in production environments.
Suika MIME is a utility library for handling MIME types within the Suika web stack (also a toy project). It provides basic functionality for determining MIME types from file extensions or paths, primarily for understanding web asset serving and for experimental purposes.
The API is subject to change. This project is not thoroughly tested or hardened for real-world applications, and documentation may be basic.
Features
- Determine MIME type from file extension.
- Determine MIME type from file path.
- Basic support for common file types.
- Intended as an illustrative example for simple MIME type handling.
Usage
Determining MIME Type from Extension
You can determine the MIME type based on a file extension using the get_mime_type function.
use suika_mime::get_mime_type;
let mime_type = get_mime_type("html");
assert_eq!(mime_type, "text/html".to_string());
let mime_type = get_mime_type("png");
assert_eq!(mime_type, "image/png".to_string());
Determining MIME Type from File Path
You can determine the MIME type based on a file path using the get_mime_type_from_path function.
use suika_mime::get_mime_type_from_path;
let mime_type = get_mime_type_from_path("index.html");
assert_eq!(mime_type, "text/html".to_string());
let mime_type = get_mime_type_from_path("images/photo.png");
assert_eq!(mime_type, "image/png".to_string());
Supported MIME Types
Suika MIME supports a range of common file types. This list is for reference and may not be exhaustive or perfectly up-to-date with external standards.
html,htm:text/htmlcss:text/cssjs,mjs:application/javascriptjson:application/jsonxml:application/xmlpdf:application/pdfzip:application/ziptar:application/x-targz:application/gzipbz2:application/x-bzip27z:application/x-7z-compressedrar:application/vnd.rarexe:application/vnd.microsoft.portable-executablemsi:application/x-msdownloadbin,dll,iso,dmg:application/octet-streampng:image/pngjpg,jpeg:image/jpeggif:image/gifsvg:image/svg+xmlbmp:image/bmpico:image/x-icontiff,tif:image/tiffwebp:image/webpmp3:audio/mpegwav:audio/wavogg:audio/oggflac:audio/flacaac:audio/aacmp4:video/mp4m4v:video/x-m4vmkv:video/x-matroskawebm:video/webmavi:video/x-msvideomov:video/quicktimewmv:video/x-ms-wmvtxt:text/plaincsv:text/csvmd:text/markdownrtf:application/rtfodt:application/vnd.oasis.opendocument.textods:application/vnd.oasis.opendocument.spreadsheetodp:application/vnd.oasis.opendocument.presentationdoc:application/msworddocx:application/vnd.openxmlformats-officedocument.wordprocessingml.documentxls:application/vnd.ms-excelxlsx:application/vnd.openxmlformats-officedocument.spreadsheetml.sheetppt:application/vnd.ms-powerpointpptx:application/vnd.openxmlformats-officedocument.presentationml.presentation