citeworks_cff/
identifiers.rs

1//! Types and utilities for identifiers e.g. DOIs.
2
3use serde::{Deserialize, Serialize};
4use url::Url;
5
6/// An identifier for a work.
7#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
8#[serde(tag = "type", rename_all = "kebab-case")]
9pub enum Identifier {
10	/// DOI
11	Doi {
12		/// The value of the DOI.
13		/// This is not parsed or validated in any way.
14		///
15		/// It should be the bare value of the DOI, not its URL or URI.
16		/// E.g. `10.5281/zenodo.1003149`.
17		value: String,
18
19		/// Optional description.
20		#[serde(default, skip_serializing_if = "Option::is_none")]
21		description: Option<String>,
22	},
23
24	/// URL
25	Url {
26		/// The value of the URL.
27		value: Url,
28
29		/// Optional description.
30		#[serde(default, skip_serializing_if = "Option::is_none")]
31		description: Option<String>,
32	},
33
34	/// Software Heritage identifier
35	Swh {
36		/// The value of the Software Heritage identifier.
37		/// This is not parsed or validated in any way.
38		///
39		/// E.g. `swh:1:dir:bc286860f423ea7ced246ba7458eef4b4541cf2d`.
40		value: String,
41
42		/// Optional description.
43		#[serde(default, skip_serializing_if = "Option::is_none")]
44		description: Option<String>,
45	},
46
47	/// Some other identifier.
48	Other {
49		/// The value of the identifier.
50		/// This is not parsed or validated in any way.
51		///
52		/// E.g. `arXiv:2103.06681`.
53		value: String,
54
55		/// Optional description.
56		#[serde(default, skip_serializing_if = "Option::is_none")]
57		description: Option<String>,
58	},
59}