1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! This crate provides two media type structs: [`MediaType`] and [`MediaTypeBuf`].
//!
//! - [`MediaType`] does not copy data during parsing
//! and borrows the original string. It is also const-constructible.
//! - [`MediaTypeBuf`] is an owned and immutable version of [`MediaType`].
//!
//! [`MadiaType`]: ./struct.MediaType.html
//! [`MediaTypeBuf`]: ./struct.MediaTypeBuf.html
//!
//! ```
//! use mediatype::{names::*, MediaType, MediaTypeBuf};
//!
//! const TEXT_PLAIN: MediaType = MediaType::new(TEXT, PLAIN);
//! let text_plain: MediaTypeBuf = "text/plain".parse().unwrap();
//!
//! assert_eq!(text_plain, TEXT_PLAIN);
//! ```
//!
//! # Letter case handling
//!
//! [`MediaType`] and [`MediaTypeBuf`] preserve the original string's letter case.
//! Comparisons for [`MediaType`], [`MediaTypeBuf`] and [`Name`] are case-insensitive
//! except parameter values.
//!
//! [`MadiaType`]: ./struct.MediaType.html
//! [`MediaTypeBuf`]: ./struct.MediaTypeBuf.html
//! [`Name`]: ./struct.Name.html
//!
//! ```
//! # use mediatype::{names::*, MediaType, MediaTypeBuf};
//! let lower: MediaTypeBuf = "text/plain; charset=UTF-8".parse().unwrap();
//! let upper: MediaTypeBuf = "TEXT/PLAIN; CHARSET=UTF-8".parse().unwrap();
//!
//! assert_eq!(lower.as_str(), "text/plain; charset=UTF-8");
//! assert_eq!(upper.as_str(), "TEXT/PLAIN; CHARSET=UTF-8");
//! assert_eq!(lower, upper);
//! assert_eq!(lower.ty(), "Text");
//! assert_eq!(upper.subty(), "Plain");
//! ```
extern crate alloc;
extern crate std;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
/// Convenient macro to construct a [`MediaType`].
///
/// [`MadiaType`]: ./struct.MediaType.html
///
///
/// ```
/// # use mediatype::media_type;
/// assert_eq!(media_type!(TEXT/PLAIN).to_string(), "text/plain");
/// assert_eq!(media_type!(IMAGE/x_::ICON).to_string(), "image/x-icon");
///
/// assert_eq!(
/// media_type!(IMAGE/SVG+XML; CHARSET=UTF_8).to_string(),
/// "image/svg+xml; charset=UTF-8"
/// );
/// assert_eq!(
/// media_type!(APPLICATION/vnd::OPENSTREETMAP_DATA+XML).to_string(),
/// "application/vnd.openstreetmap.data+xml"
/// );
/// ```