Skip to main content

crossref/
cn.rs

1use serde::Serialize;
2
3#[derive(Debug, Clone, Serialize)]
4#[allow(missing_docs)]
5pub enum CnFormat {
6    RdfXml,
7    Turtle,
8    CiteProcJson,
9    CiteProcJsonIsh,
10    Text,
11    Ris,
12    BibTex,
13    CrossrefXml,
14    DataciteXml,
15    BibEntry,
16    CrossrefTdm,
17}
18
19impl CnFormat {
20    /// the mime identifier
21    pub fn mime_type(&self) -> &str {
22        match self {
23            CnFormat::RdfXml => "text/xml",
24            CnFormat::Turtle => "text/plain",
25            CnFormat::CiteProcJson => "application/json",
26            CnFormat::CiteProcJsonIsh => "application/json",
27            CnFormat::Text => "text/plain",
28            CnFormat::Ris => "text/plain",
29            CnFormat::BibTex => "text/xml",
30            CnFormat::CrossrefXml => "text/xml",
31            CnFormat::DataciteXml => "",
32            CnFormat::BibEntry => "text/plain",
33            CnFormat::CrossrefTdm => "text/xml",
34        }
35    }
36    /// the mime type's header
37    pub fn header(&self) -> &str {
38        match self {
39            CnFormat::RdfXml => "application/rdf+xml",
40            CnFormat::Turtle => "text/turtle",
41            CnFormat::CiteProcJson | CnFormat::CiteProcJsonIsh => {
42                "transform/application/vnd.citationstyles.csl+json"
43            }
44            CnFormat::Text => "text/x-bibliography",
45            CnFormat::Ris => "application/x-research-info-systems",
46            CnFormat::BibTex => "application/x-bibtex",
47            CnFormat::CrossrefXml => "application/vnd.crossref.unixref+xml",
48            CnFormat::DataciteXml => "application/vnd.datacite.datacite+xml",
49            CnFormat::BibEntry => "application/x-bibtex",
50            CnFormat::CrossrefTdm => "application/vnd.crossref.unixsd+xml",
51        }
52    }
53}