zugferd_code_lists/zugferd_2_3_3/
mime.rs1#![allow(non_camel_case_types)]
2
3#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
4pub enum MIME {
5 ApplicationPdf,
7 ImagePng,
9 ImageJpeg,
11 TextCsv,
13 ApplicationVndOpenxmlformatsOfficedocumentSpreadsheetmlSheet,
15 ApplicationVndOasisOpendocumentSpreadsheet,
17 ApplicationXml,
19 TextXml,
21}
22
23impl crate::Code for MIME {
24 fn code(self) -> &'static str {
25 match self {
26 MIME::ApplicationPdf => "application/pdf",
27 MIME::ImagePng => "image/png",
28 MIME::ImageJpeg => "image/jpeg",
29 MIME::TextCsv => "text/csv",
30 MIME::ApplicationVndOpenxmlformatsOfficedocumentSpreadsheetmlSheet => {
31 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
32 }
33 MIME::ApplicationVndOasisOpendocumentSpreadsheet => {
34 "application/vnd.oasis.opendocument.spreadsheet"
35 }
36 MIME::ApplicationXml => "application/xml",
37 MIME::TextXml => "text/xml",
38 }
39 }
40}
41
42impl crate::Description for MIME {
43 fn description(self) -> &'static str {
44 match self {
45 MIME::ApplicationPdf => "application/pdf",
46 MIME::ImagePng => "image/png",
47 MIME::ImageJpeg => "image/jpeg",
48 MIME::TextCsv => "text/csv",
49 MIME::ApplicationVndOpenxmlformatsOfficedocumentSpreadsheetmlSheet => {
50 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
51 }
52 MIME::ApplicationVndOasisOpendocumentSpreadsheet => {
53 "application/vnd.oasis.opendocument.spreadsheet"
54 }
55 MIME::ApplicationXml => "application/xml",
56 MIME::TextXml => "text/xml",
57 }
58 }
59}
60
61impl crate::FromCode for MIME {
62 fn from_code(code: &str) -> Option<Self>
63 where
64 Self: Sized,
65 {
66 match code {
67 "application/pdf" => Some(MIME::ApplicationPdf),
68 "image/png" => Some(MIME::ImagePng),
69 "image/jpeg" => Some(MIME::ImageJpeg),
70 "text/csv" => Some(MIME::TextCsv),
71 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" => {
72 Some(MIME::ApplicationVndOpenxmlformatsOfficedocumentSpreadsheetmlSheet)
73 }
74 "application/vnd.oasis.opendocument.spreadsheet" => {
75 Some(MIME::ApplicationVndOasisOpendocumentSpreadsheet)
76 }
77 "application/xml" => Some(MIME::ApplicationXml),
78 "text/xml" => Some(MIME::TextXml),
79 _ => None,
80 }
81 }
82}