Expand description
Parser and handler for MIME types.
This crate provides a type, Mime, which represents a MIME type as defined in
RFC 2045 and RFC 2046.
The aim of this library is to provide strongly typed MIME types that are an overall improvement over
just repesenting MIME types as strings.
§Example
use mr_mime::{Mime, constants};
// Parse a MIME type from a string.
let my_type = Mime::parse("text/html; charset=utf-8").unwrap();
// Get the "essence" of a MIME type.
let essence = my_type.essence();
// Compare it to a wide variety of constants.
assert_eq!(essence, constants::TEXT_HTML);§Features
This crate has the following features:
std, enabled by default, which enables the standard library. This is used to implementstd::error::ErrorforParseError.alloc, enabled by default, which enables thealloccrate. This is used to implement hashing for MIME types. By default, the hashing algorithm tries to use stack space, but for strings longer than 128 bytes this can lead to a panic. Theallocfeature ameliorates this by using the heap instead.
Modules§
- constants
- Constants for common MIME types and subtypes.
Structs§
- Mime
- A MIME type.
- Subtype
- The subtype name of a MIME type.
- Suffix
- The suffix name of a MIME type.
- Type
- The type name of a MIME type.
Enums§
- Parse
Error - MIME type parsing error.