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
#[derive(Debug, Clone, Serialize)]
#[allow(missing_docs)]
pub enum CnFormat {
    RdfXml,
    Turtle,
    CiteProcJson,
    CiteProcJsonIsh,
    Text,
    Ris,
    BibTex,
    CrossrefXml,
    DataciteXml,
    BibEntry,
    CrossrefTdm,
}

impl CnFormat {
    /// the mime identifier
    pub fn mime_type(&self) -> &str {
        match self {
            CnFormat::RdfXml => "text/xml",
            CnFormat::Turtle => "text/plain",
            CnFormat::CiteProcJson => "application/json",
            CnFormat::CiteProcJsonIsh => "application/json",
            CnFormat::Text => "text/plain",
            CnFormat::Ris => "text/plain",
            CnFormat::BibTex => "text/xml",
            CnFormat::CrossrefXml => "text/xml",
            CnFormat::DataciteXml => "",
            CnFormat::BibEntry => "text/plain",
            CnFormat::CrossrefTdm => "text/xml",
        }
    }
    /// the mime type's header
    pub fn header(&self) -> &str {
        match self {
            CnFormat::RdfXml => "application/rdf+xml",
            CnFormat::Turtle => "text/turtle",
            CnFormat::CiteProcJson | CnFormat::CiteProcJsonIsh => {
                "transform/application/vnd.citationstyles.csl+json"
            }
            CnFormat::Text => "text/x-bibliography",
            CnFormat::Ris => "application/x-research-info-systems",
            CnFormat::BibTex => "application/x-bibtex",
            CnFormat::CrossrefXml => "application/vnd.crossref.unixref+xml",
            CnFormat::DataciteXml => "application/vnd.datacite.datacite+xml",
            CnFormat::BibEntry => "application/x-bibtex",
            CnFormat::CrossrefTdm => "application/vnd.crossref.unixsd+xml",
        }
    }
}