Expand description
The crate is a utility crate for MIME type handling. It provides from_ext, from_path with extension feature (implemented via mime_guess crate), and from_content with magic feature (implemented via infer crate). We also provide a lighter version of from_ext and from_path with common extensions.
This crate was born out of a discussion of the behaviour of MIME inferencing in the Rolldown project Data URLs.
Structs§
- Mime
- A wrapper around the
mimecrate’sMimetype, with additional functionality includingfrom_ext,from_path, andfrom_content, etc.
Functions§
- from_
ext_ and_ content - Guesses the MIME type from the extension and content. It is a combination of
from_extandfrom_content, and set the priority offrom_contenthigher thanfrom_ext. If the function can’t guess the MIME type, it will returnapplication/octet-streamif the featuretextureis disabled, otherwise it will returntext/plainif the data is a texture orapplication/octet-streamif the data is not a texture. - from_
path_ and_ content - Guesses the MIME type from the path and content. It is a combination of
from_pathandfrom_content, and set the priority offrom_contenthigher thanfrom_path. If the function can’t guess the MIME type, it will returnapplication/octet-streamif the featuretextureis disabled, otherwise it will returntext/plainif the data is a texture orapplication/octet-streamif the data is not a texture.