c2pa-rs

A fork of https://github.com/contentauth/c2pa-rs/
git clone git://archive.git.mtrnord.blog/mtrnords-photography-manager/c2pa-rs.git
Log | Files | Refs | README

commit 3726b0aaddf3f33b3ab50ddc3cf3698212aa8a4f
parent 4113ec8a343c8f2d1103e111d48ae869a70af657
Author: Gavin  Peacock <gpeacock@adobe.com>
Date:   Mon, 14 Nov 2022 12:27:17 -0800

Support digitalSourceType field in Action (#154)

Support DigitalSourceType in Action
Diffstat:
Msdk/src/assertions/actions.rs | 26++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/sdk/src/assertions/actions.rs b/sdk/src/assertions/actions.rs @@ -98,6 +98,10 @@ pub struct Action { /// An array of the creators that undertook this action. #[serde(skip_serializing_if = "Option::is_none")] actors: Option<Vec<Actor>>, + + /// One of the defined URI values at `<https://cv.iptc.org/newscodes/digitalsourcetype/>` + #[serde(rename = "digitalSourceType", skip_serializing_if = "Option::is_none")] + source_type: Option<String>, } impl Action { @@ -114,6 +118,7 @@ impl Action { instance_id: None, parameters: None, actors: None, + source_type: None, } } @@ -163,6 +168,11 @@ impl Action { self.actors.as_deref() } + /// Returns a digitalSourceType as defined at <https://cv.iptc.org/newscodes/digitalsourcetype/>. + pub fn source_type(&self) -> Option<&str> { + self.source_type.as_deref() + } + /// Sets the timestamp for when the action occurred. /// /// This timestamp must be in ISO-8601 date. @@ -219,6 +229,12 @@ impl Action { self.actors = actors.cloned(); self } + + /// Set a digitalSourceType URI as defined at <https://cv.iptc.org/newscodes/digitalsourcetype/>. + pub fn set_source_type<S: Into<String>>(mut self, uri: S) -> Self { + self.source_type = Some(uri.into()); + self + } } /// An `Actions` assertion provides information on edits and other @@ -359,7 +375,8 @@ pub mod tests { Action::new("c2pa.filtered") .set_parameter("name".to_owned(), "gaussian blur") .unwrap() - .set_when("2015-06-26T16:43:23+0200"), + .set_when("2015-06-26T16:43:23+0200") + .set_source_type("digsrctype:algorithmicMedia"), ) .add_metadata( Metadata::new() @@ -388,6 +405,10 @@ pub mod tests { ); assert_eq!(result.actions[1].when(), original.actions[1].when()); assert_eq!( + result.actions[1].source_type().unwrap(), + "digsrctype:algorithmicMedia" + ); + assert_eq!( result.metadata.unwrap().date_time(), original.metadata.unwrap().date_time() ); @@ -497,7 +518,8 @@ pub mod tests { "action": "c2pa.edited", "parameters": { "description": "import" - } + }, + "digitalSourceType": "http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia" }, ], "metadata": {