13
13
14
14
use std:: { collections:: HashMap , fmt} ;
15
15
16
+ #[ cfg( feature = "json_schema" ) ]
17
+ use schemars:: JsonSchema ;
16
18
use serde:: { de:: DeserializeOwned , Deserialize , Serialize } ;
17
19
use serde_cbor:: Value ;
18
20
@@ -28,175 +30,164 @@ use crate::{
28
30
const ASSERTION_CREATION_VERSION : usize = 2 ;
29
31
pub const INGREDIENT_IDS : & str = "ingredientIds" ;
30
32
31
- // TODO: this is needed to supress clippy deprecated field warning: https://github.com/serde-rs/serde/pull/2879
32
- pub use digital_source_type:: DigitalSourceType ;
33
- mod digital_source_type {
34
- #![ allow( deprecated) ]
35
-
36
- #[ cfg( feature = "json_schema" ) ]
37
- use schemars:: JsonSchema ;
38
-
39
- use super :: * ;
40
-
41
- /// Description of the source of an asset.
42
- ///
43
- /// The full list of possible digital source types are found below:
44
- /// <https://spec.c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_digital_source_type>
45
- /// <https://cv.iptc.org/newscodes/digitalsourcetype>
46
- #[ non_exhaustive]
47
- #[ derive( Deserialize , Serialize , Clone , Debug , PartialEq ) ]
48
- #[ cfg_attr( feature = "json_schema" , derive( JsonSchema ) ) ]
49
- pub enum DigitalSourceType {
50
- /// Media whose digital content is effectively empty, such as a blank canvas or zero-length video.
51
- #[ serde( alias = "empty" , rename = "http://c2pa.org/digitalsourcetype/empty" ) ]
52
- Empty ,
53
- /// Data that is the result of algorithmically using a model derived from sampled content and data.
54
- /// Differs from <http://cv.iptc.org/newscodes/digitalsourcetype/>trainedAlgorithmicMedia in that
55
- /// the result isn’t a media type (e.g., image or video) but is a data format (e.g., CSV, pickle).
56
- #[ serde(
57
- alias = "trainedAlgorithmicData" ,
58
- rename = "http://c2pa.org/digitalsourcetype/trainedAlgorithmicData"
59
- ) ]
60
- TrainedAlgorithmicData ,
61
- /// The media was captured from a real-life source using a digital camera or digital recording device.
62
- #[ serde(
63
- alias = "digitalCapture" ,
64
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture"
65
- ) ]
66
- DigitalCapture ,
67
- /// The media is the result of capturing multiple frames from a real-life source using a digital camera
68
- /// or digital recording device, then automatically merging them into a single frame using digital signal
69
- /// processing techniques and/or non-generative AI. Includes High Dynamic Range (HDR) processing common in
70
- /// smartphone camera apps.
71
- #[ serde(
72
- alias = "computationalCapture" ,
73
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/computationalCapture"
74
- ) ]
75
- ComputationalCapture ,
76
- /// The media was digitised from a negative on film or other transparent medium.
77
- #[ serde(
78
- alias = "negativeFilm" ,
79
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/negativeFilm"
80
- ) ]
81
- NegativeFilm ,
82
- /// The media was digitised from a positive on a transparency or other transparent medium.
83
- #[ serde(
84
- alias = "positiveFilm" ,
85
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/positiveFilm"
86
- ) ]
87
- PositiveFilm ,
88
- /// The media was digitised from a non-transparent medium such as a photographic print.
89
- #[ serde(
90
- alias = "print" ,
91
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/print"
92
- ) ]
93
- Print ,
94
- /// Minor augmentation or correction by a human, such as a digitally-retouched photo used in a magazine.
95
- #[ deprecated]
96
- #[ serde(
97
- alias = "minorHumanEdits" ,
98
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/minorHumanEdits"
99
- ) ]
100
- MinorHumanEdits ,
101
- /// Augmentation, correction or enhancement by one or more humans using non-generative tools.
102
- #[ serde(
103
- alias = "humanEdits" ,
104
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/humanEdits"
105
- ) ]
106
- HumanEdits ,
107
- /// Augmentation, correction or enhancement using a Generative AI model, such as with inpainting or
108
- /// outpainting operations.
109
- #[ serde(
110
- alias = "compositeWithTrainedAlgorithmicMedia" ,
111
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/compositeWithTrainedAlgorithmicMedia"
112
- ) ]
113
- CompositeWithTrainedAlgorithmicMedia ,
114
- /// Modification or correction by algorithm without changing the main content of the media, initiated
115
- /// or configured by a human, such as sharpening or applying noise reduction.
116
- #[ serde(
117
- alias = "algorithmicallyEnhanced" ,
118
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicallyEnhanced"
119
- ) ]
120
- AlgorithmicallyEnhanced ,
121
- /// The digital image was created by computer software.
122
- #[ deprecated]
123
- #[ serde(
124
- alias = "softwareImage" ,
125
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage"
126
- ) ]
127
- SoftwareImage ,
128
- /// Media created by a human using digital tools.
129
- #[ deprecated]
130
- #[ serde(
131
- alias = "digitalArt" ,
132
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/digitalArt"
133
- ) ]
134
- DigitalArt ,
135
- /// Media created by a human using non-generative tools.
136
- #[ serde(
137
- alias = "digitalCreation" ,
138
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/digitalCreation"
139
- ) ]
140
- DigitalCreation ,
141
- /// Digital media representation of data via human programming or creativity.
142
- #[ serde(
143
- alias = "dataDrivenMedia" ,
144
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/dataDrivenMedia"
145
- ) ]
146
- DataDrivenMedia ,
147
- /// Digital media created algorithmically using an Artificial Intelligence model trained on captured
148
- /// content.
149
- #[ serde(
150
- alias = "trainedAlgorithmicMedia" ,
151
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia"
152
- ) ]
153
- TrainedAlgorithmicMedia ,
154
- /// Media created purely by an algorithm not based on any sampled training data, e.g. an image created
155
- /// by software using a mathematical formula.
156
- #[ serde(
157
- alias = "algorithmicMedia" ,
158
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"
159
- ) ]
160
- AlgorithmicMedia ,
161
- /// A capture of the contents of the screen of a computer or mobile device.
162
- #[ serde(
163
- alias = "screenCapture" ,
164
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/screenCapture"
165
- ) ]
166
- ScreenCapture ,
167
- /// Live recording of virtual event based on Generative AI and/or captured elements.
168
- #[ serde(
169
- alias = "virtualRecording" ,
170
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/virtualRecording"
171
- ) ]
172
- VirtualRecording ,
173
- /// Mix or composite of several elements, any of which may or may not be generative AI.
174
- #[ serde(
175
- alias = "composite" ,
176
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/composite"
177
- ) ]
178
- Composite ,
179
- /// Mix or composite of several elements that are all captures of real life.
180
- #[ serde(
181
- alias = "compositeCapture" ,
182
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/compositeCapture"
183
- ) ]
184
- CompositeCapture ,
185
- /// Mix or composite of several elements, at least one of which is Generative AI.
186
- #[ serde(
187
- alias = "compositeSynthetic" ,
188
- rename = "http://cv.iptc.org/newscodes/digitalsourcetype/compositeSynthetic"
189
- ) ]
190
- CompositeSynthetic ,
191
- /// An unknown digital source type.
192
- #[ serde( untagged) ]
193
- Other ( String ) ,
194
- }
33
+ /// Description of the source of an asset.
34
+ ///
35
+ /// The full list of possible digital source types are found below:
36
+ /// <https://spec.c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_digital_source_type>
37
+ /// <https://cv.iptc.org/newscodes/digitalsourcetype>
38
+ #[ non_exhaustive]
39
+ #[ derive( Deserialize , Serialize , Clone , Debug , PartialEq ) ]
40
+ #[ cfg_attr( feature = "json_schema" , derive( JsonSchema ) ) ]
41
+ pub enum DigitalSourceType {
42
+ /// Media whose digital content is effectively empty, such as a blank canvas or zero-length video.
43
+ #[ serde( alias = "empty" , rename = "http://c2pa.org/digitalsourcetype/empty" ) ]
44
+ Empty ,
45
+ /// Data that is the result of algorithmically using a model derived from sampled content and data.
46
+ /// Differs from <http://cv.iptc.org/newscodes/digitalsourcetype/>trainedAlgorithmicMedia in that
47
+ /// the result isn’t a media type (e.g., image or video) but is a data format (e.g., CSV, pickle).
48
+ #[ serde(
49
+ alias = "trainedAlgorithmicData" ,
50
+ rename = "http://c2pa.org/digitalsourcetype/trainedAlgorithmicData"
51
+ ) ]
52
+ TrainedAlgorithmicData ,
53
+ /// The media was captured from a real-life source using a digital camera or digital recording device.
54
+ #[ serde(
55
+ alias = "digitalCapture" ,
56
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture"
57
+ ) ]
58
+ DigitalCapture ,
59
+ /// The media is the result of capturing multiple frames from a real-life source using a digital camera
60
+ /// or digital recording device, then automatically merging them into a single frame using digital signal
61
+ /// processing techniques and/or non-generative AI. Includes High Dynamic Range (HDR) processing common in
62
+ /// smartphone camera apps.
63
+ #[ serde(
64
+ alias = "computationalCapture" ,
65
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/computationalCapture"
66
+ ) ]
67
+ ComputationalCapture ,
68
+ /// The media was digitised from a negative on film or other transparent medium.
69
+ #[ serde(
70
+ alias = "negativeFilm" ,
71
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/negativeFilm"
72
+ ) ]
73
+ NegativeFilm ,
74
+ /// The media was digitised from a positive on a transparency or other transparent medium.
75
+ #[ serde(
76
+ alias = "positiveFilm" ,
77
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/positiveFilm"
78
+ ) ]
79
+ PositiveFilm ,
80
+ /// The media was digitised from a non-transparent medium such as a photographic print.
81
+ #[ serde(
82
+ alias = "print" ,
83
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/print"
84
+ ) ]
85
+ Print ,
86
+ /// Minor augmentation or correction by a human, such as a digitally-retouched photo used in a magazine.
87
+ #[ deprecated]
88
+ #[ serde(
89
+ alias = "minorHumanEdits" ,
90
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/minorHumanEdits"
91
+ ) ]
92
+ MinorHumanEdits ,
93
+ /// Augmentation, correction or enhancement by one or more humans using non-generative tools.
94
+ #[ serde(
95
+ alias = "humanEdits" ,
96
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/humanEdits"
97
+ ) ]
98
+ HumanEdits ,
99
+ /// Augmentation, correction or enhancement using a Generative AI model, such as with inpainting or
100
+ /// outpainting operations.
101
+ #[ serde(
102
+ alias = "compositeWithTrainedAlgorithmicMedia" ,
103
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/compositeWithTrainedAlgorithmicMedia"
104
+ ) ]
105
+ CompositeWithTrainedAlgorithmicMedia ,
106
+ /// Modification or correction by algorithm without changing the main content of the media, initiated
107
+ /// or configured by a human, such as sharpening or applying noise reduction.
108
+ #[ serde(
109
+ alias = "algorithmicallyEnhanced" ,
110
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicallyEnhanced"
111
+ ) ]
112
+ AlgorithmicallyEnhanced ,
113
+ /// The digital image was created by computer software.
114
+ #[ deprecated]
115
+ #[ serde(
116
+ alias = "softwareImage" ,
117
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage"
118
+ ) ]
119
+ SoftwareImage ,
120
+ /// Media created by a human using digital tools.
121
+ #[ deprecated]
122
+ #[ serde(
123
+ alias = "digitalArt" ,
124
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/digitalArt"
125
+ ) ]
126
+ DigitalArt ,
127
+ /// Media created by a human using non-generative tools.
128
+ #[ serde(
129
+ alias = "digitalCreation" ,
130
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/digitalCreation"
131
+ ) ]
132
+ DigitalCreation ,
133
+ /// Digital media representation of data via human programming or creativity.
134
+ #[ serde(
135
+ alias = "dataDrivenMedia" ,
136
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/dataDrivenMedia"
137
+ ) ]
138
+ DataDrivenMedia ,
139
+ /// Digital media created algorithmically using an Artificial Intelligence model trained on captured
140
+ /// content.
141
+ #[ serde(
142
+ alias = "trainedAlgorithmicMedia" ,
143
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia"
144
+ ) ]
145
+ TrainedAlgorithmicMedia ,
146
+ /// Media created purely by an algorithm not based on any sampled training data, e.g. an image created
147
+ /// by software using a mathematical formula.
148
+ #[ serde(
149
+ alias = "algorithmicMedia" ,
150
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia"
151
+ ) ]
152
+ AlgorithmicMedia ,
153
+ /// A capture of the contents of the screen of a computer or mobile device.
154
+ #[ serde(
155
+ alias = "screenCapture" ,
156
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/screenCapture"
157
+ ) ]
158
+ ScreenCapture ,
159
+ /// Live recording of virtual event based on Generative AI and/or captured elements.
160
+ #[ serde(
161
+ alias = "virtualRecording" ,
162
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/virtualRecording"
163
+ ) ]
164
+ VirtualRecording ,
165
+ /// Mix or composite of several elements, any of which may or may not be generative AI.
166
+ #[ serde(
167
+ alias = "composite" ,
168
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/composite"
169
+ ) ]
170
+ Composite ,
171
+ /// Mix or composite of several elements that are all captures of real life.
172
+ #[ serde(
173
+ alias = "compositeCapture" ,
174
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/compositeCapture"
175
+ ) ]
176
+ CompositeCapture ,
177
+ /// Mix or composite of several elements, at least one of which is Generative AI.
178
+ #[ serde(
179
+ alias = "compositeSynthetic" ,
180
+ rename = "http://cv.iptc.org/newscodes/digitalsourcetype/compositeSynthetic"
181
+ ) ]
182
+ CompositeSynthetic ,
183
+ /// An unknown digital source type.
184
+ #[ serde( untagged) ]
185
+ Other ( String ) ,
186
+ }
195
187
196
- impl fmt:: Display for DigitalSourceType {
197
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
198
- self . serialize ( f)
199
- }
188
+ impl fmt:: Display for DigitalSourceType {
189
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
190
+ self . serialize ( f)
200
191
}
201
192
}
202
193
0 commit comments