1use data_url::mime::Mime;
6use headers::ContentType;
7
8pub(crate) static APPLICATION: &str = "application";
9pub(crate) static CHARSET: &str = "charset";
10pub(crate) static HTML: &str = "html";
11pub(crate) static TEXT: &str = "text";
12pub(crate) static XML: &str = "xml";
13
14pub(crate) trait MimeExt {
16 fn has_suffix(&self, suffix: &str) -> bool;
19
20 fn clone(&self) -> Self;
22
23 fn from_ct(ct: ContentType) -> Self;
25}
26
27impl MimeExt for Mime {
28 fn has_suffix(&self, suffix: &str) -> bool {
29 self.subtype.ends_with(&format!("+{}", suffix))
30 }
31
32 fn clone(&self) -> Self {
33 Self {
34 type_: self.type_.clone(),
35 subtype: self.subtype.clone(),
36 parameters: self.parameters.clone(),
37 }
38 }
39
40 fn from_ct(ct: ContentType) -> Self {
41 ct.to_string().parse().unwrap()
42 }
43}