Skip to main content

mediatypes/
lib.rs

1//! # mediatypes
2//!
3//! A comprehensive collection of MIME types (media types) as string constants.
4//!
5//! This crate provides an organized, hierarchical structure of all standard MIME types
6//! registered with IANA, making it easy to reference media types in a type-safe manner.
7//!
8//! ## Usage
9//!
10//! ```rust
11//! use mediatypes::application::X_WWW_FORM_URLENCODED;
12//! use mediatypes::image::PNG;
13//! use mediatypes::text::HTML;
14//!
15//! assert_eq!(X_WWW_FORM_URLENCODED, "application/x-www-form-urlencoded");
16//! assert_eq!(PNG, "image/png");
17//! assert_eq!(HTML, "text/html");
18//! ```
19//!
20//! ## Organization
21//!
22//! MIME types are organized by their top-level type:
23//! - `application` - Application-specific data
24//! - `audio` - Audio data
25//! - `chemical` - Chemical data and molecular structures
26//! - `font` - Font data
27//! - `image` - Image data
28//! - `message` - Message protocol data
29//! - `model` - 3D model data
30//! - `multipart` - Multi-part data
31//! - `text` - Human-readable text
32//! - `video` - Video data
33//! - `x_conference` - Conference-related experimental types
34//! - `x_shader` - Shader-related experimental types
35
36#![warn(missing_docs)]
37#![deny(unsafe_code)]
38
39/// Application-specific MIME types
40pub mod application;
41/// Audio MIME types
42pub mod audio;
43/// Chemical MIME types
44pub mod chemical;
45/// Font MIME types
46pub mod font;
47/// Image MIME types
48pub mod image;
49/// Message protocol MIME types
50pub mod message;
51/// 3D model MIME types
52pub mod model;
53/// Multi-part MIME types
54pub mod multipart;
55/// Text MIME types
56pub mod text;
57/// Video MIME types
58pub mod video;
59/// Conference-related experimental MIME types
60pub mod x_conference;
61/// Shader-related experimental MIME types
62pub mod x_shader;
63
64/// Helper module for tests - exports all MIME types as a vector
65///
66/// This module is automatically generated and is primarily intended for testing.
67#[doc(hidden)]
68pub mod all_types;
69
70#[cfg(test)]
71mod tests {
72    use super::*;
73
74    #[test]
75    fn test_application_types() {
76        assert_eq!(application::JSON, "application/json");
77        assert_eq!(application::XML, "application/xml");
78        assert_eq!(application::PDF, "application/pdf");
79    }
80
81    #[test]
82    fn test_text_types() {
83        assert_eq!(text::PLAIN, "text/plain");
84        assert_eq!(text::HTML, "text/html");
85        assert_eq!(text::CSS, "text/css");
86    }
87
88    #[test]
89    fn test_image_types() {
90        assert_eq!(image::PNG, "image/png");
91        assert_eq!(image::JPEG, "image/jpeg");
92        assert_eq!(image::GIF, "image/gif");
93    }
94
95    #[test]
96    fn test_video_types() {
97        assert_eq!(video::MP4, "video/mp4");
98        assert_eq!(video::WEBM, "video/webm");
99    }
100
101    #[test]
102    fn test_audio_types() {
103        assert_eq!(audio::MPEG, "audio/mpeg");
104        assert_eq!(audio::WAV, "audio/wav");
105    }
106}