Skip to main content

postproject_core/metadata_registry/
catalog.rs

1//! Deliberately small built-in metadata catalog.
2
3use super::{
4    MetadataCardinality, MetadataPropertyAlias, MetadataPropertyDefinition,
5    MetadataVocabularyDefinition,
6};
7use crate::MetadataValueKind;
8
9/// IPTC Video Metadata Hub 1.7 JSON schema identity.
10pub const IPTC_VMH_JSON_VOCABULARY: &str =
11    "https://iptc.org/std/videometadatahub/recommendation/iptc-vmhub-1.7-schema.json";
12/// Dublin Core elements namespace used by XMP and other mappings.
13pub const DUBLIN_CORE_ELEMENTS_VOCABULARY: &str = "http://purl.org/dc/elements/1.1/";
14/// Adobe XMP Basic namespace.
15pub const XMP_BASIC_VOCABULARY: &str = "http://ns.adobe.com/xap/1.0/";
16/// Current `EBUCore` namespace identity.
17pub const EBUCORE_VOCABULARY: &str = "urn:ebu:metadata-schema:ebucore";
18/// Namespace reserved for the small set of PostProject-owned metadata terms.
19pub const POSTPROJECT_METADATA_VOCABULARY: &str = "https://postproject.org/ns/metadata/";
20
21const TEXT: &[MetadataValueKind] = &[MetadataValueKind::String, MetadataValueKind::LangString];
22const STRING: &[MetadataValueKind] = &[MetadataValueKind::String];
23const TIMESTAMP: &[MetadataValueKind] = &[MetadataValueKind::Timestamp];
24
25const TITLE_ALIASES: &[MetadataPropertyAlias] =
26    &[alias("XMP", "dc:title"), alias("EBUCore", "title/dc:title")];
27const KEYWORD_ALIASES: &[MetadataPropertyAlias] = &[
28    alias("XMP", "dc:subject"),
29    alias("EBUCore", "description/dc:description"),
30];
31
32const IPTC_VMH_PROPERTIES: &[MetadataPropertyDefinition] = &[
33    property(
34        "title",
35        "Title",
36        "A short title for the video.",
37        TEXT,
38        MetadataCardinality::Single,
39        TITLE_ALIASES,
40    ),
41    property(
42        "keywords",
43        "Keywords",
44        "Free-choice phrases describing what the video is about.",
45        TEXT,
46        MetadataCardinality::Repeatable,
47        KEYWORD_ALIASES,
48    ),
49];
50
51const DUBLIN_CORE_PROPERTIES: &[MetadataPropertyDefinition] = &[
52    property(
53        "title",
54        "Title",
55        "A name given to the resource.",
56        TEXT,
57        MetadataCardinality::Repeatable,
58        &[],
59    ),
60    property(
61        "subject",
62        "Subject",
63        "A topic of the resource.",
64        TEXT,
65        MetadataCardinality::Repeatable,
66        &[],
67    ),
68];
69
70const XMP_BASIC_PROPERTIES: &[MetadataPropertyDefinition] = &[
71    property(
72        "CreateDate",
73        "Create date",
74        "The date and time the resource was originally created.",
75        TIMESTAMP,
76        MetadataCardinality::Single,
77        &[],
78    ),
79    property(
80        "CreatorTool",
81        "Creator tool",
82        "The first known tool used to create the resource.",
83        STRING,
84        MetadataCardinality::Single,
85        &[],
86    ),
87];
88
89/// Small built-in registry. Unknown vocabularies and properties remain valid.
90pub const METADATA_VOCABULARIES: &[MetadataVocabularyDefinition] = &[
91    vocabulary(
92        IPTC_VMH_JSON_VOCABULARY,
93        "IPTC Video Metadata Hub 1.7 JSON",
94        IPTC_VMH_JSON_VOCABULARY,
95        IPTC_VMH_PROPERTIES,
96    ),
97    vocabulary(
98        DUBLIN_CORE_ELEMENTS_VOCABULARY,
99        "Dublin Core elements",
100        "https://www.dublincore.org/specifications/dublin-core/dces/",
101        DUBLIN_CORE_PROPERTIES,
102    ),
103    vocabulary(
104        XMP_BASIC_VOCABULARY,
105        "XMP Basic",
106        "https://developer.adobe.com/xmp/docs/xmp-namespaces/xmp/",
107        XMP_BASIC_PROPERTIES,
108    ),
109    vocabulary(
110        EBUCORE_VOCABULARY,
111        "EBUCore",
112        "https://tech.ebu.ch/publications/tech3293",
113        &[],
114    ),
115    vocabulary(
116        POSTPROJECT_METADATA_VOCABULARY,
117        "PostProject metadata",
118        POSTPROJECT_METADATA_VOCABULARY,
119        &[],
120    ),
121];
122
123const fn alias(profile: &'static str, property: &'static str) -> MetadataPropertyAlias {
124    MetadataPropertyAlias { profile, property }
125}
126
127const fn property(
128    property: &'static str,
129    label: &'static str,
130    description: &'static str,
131    accepted_kinds: &'static [MetadataValueKind],
132    cardinality: MetadataCardinality,
133    aliases: &'static [MetadataPropertyAlias],
134) -> MetadataPropertyDefinition {
135    MetadataPropertyDefinition {
136        property,
137        label,
138        description,
139        accepted_kinds,
140        cardinality,
141        aliases,
142        validator: None,
143    }
144}
145
146const fn vocabulary(
147    vocabulary: &'static str,
148    label: &'static str,
149    reference: &'static str,
150    properties: &'static [MetadataPropertyDefinition],
151) -> MetadataVocabularyDefinition {
152    MetadataVocabularyDefinition {
153        vocabulary,
154        label,
155        reference,
156        properties,
157    }
158}