1pub trait Field {
3 const NAME: &'static str;
5 const NAMESPACE: Namespace;
9}
10
11const XML_NS_TIFF: &str = "http://ns.adobe.com/tiff/1.0/";
13const XML_NS_EXIF: &str = "http://ns.adobe.com/exif/1.0/";
15const XML_NS_EXIF_EX: &str = "http://cipa.jp/exif/1.0/";
17
18const XML_NS_XMP: &str = "http://ns.adobe.com/xap/1.0/";
19const XML_NS_XMP_RIGHTS: &str = "http://ns.adobe.com/xap/1.0/rights/";
20pub const XML_NS_RDF: &str = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
22const XML_NS_PS: &str = "http://ns.adobe.com/photoshop/1.0/";
23const XML_NS_DC: &str = "http://purl.org/dc/elements/1.1/";
24
25#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
26pub enum Namespace {
27 Tiff,
29 Exif,
31 ExifEX,
33 Ps,
34 Dc,
35 Xmp,
36 XmpRights,
37 Unknown(String),
38}
39
40impl Namespace {
41 pub fn from_url(url: &str) -> Self {
42 match url {
43 XML_NS_TIFF => Namespace::Tiff,
44 XML_NS_EXIF => Namespace::Exif,
45 XML_NS_EXIF_EX => Namespace::ExifEX,
46 XML_NS_XMP => Namespace::Xmp,
47 XML_NS_XMP_RIGHTS => Namespace::XmpRights,
48 XML_NS_PS => Namespace::Ps,
49 XML_NS_DC => Namespace::Dc,
50 namespace => Namespace::Unknown(namespace.to_string()),
51 }
52 }
53
54 pub fn to_url(&self) -> &str {
55 match self {
56 Namespace::Tiff => XML_NS_TIFF,
57 Namespace::Exif => XML_NS_EXIF,
58 Namespace::ExifEX => XML_NS_EXIF_EX,
59 Namespace::Xmp => XML_NS_XMP,
60 Namespace::XmpRights => XML_NS_XMP_RIGHTS,
61 Namespace::Ps => XML_NS_PS,
62 Namespace::Dc => XML_NS_DC,
63 Namespace::Unknown(namespace) => namespace.as_str(),
64 }
65 }
66}