Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion sdk/src/assertions/ingredient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub struct Ingredient {
pub active_manifest: Option<HashedUri>,
pub claim_signature: Option<HashedUri>,

pub soft_bindings_matched: Option<bool>,
pub soft_binding_algorithms_matched: Option<Vec<String>>,
pub version: usize,
}

Expand Down Expand Up @@ -409,6 +411,8 @@ impl Ingredient {
? "thumbnail": $hashed-uri-map, ; hashed_uri reference to a thumbnail in a data box
? "description": tstr .size (1..max-tstr-length), ; Additional description of the ingredient
? "informationalURI": tstr .size (1..max-tstr-length), ; URI to an informational page about the ingredient or its data
? "softBindingsMatched": bool, ; Whether soft bindings were matched
? "softBindingAlgorithmsMatched": [1* tstr] ; Array of algorithm names used for discovering the active manifest
? "metadata": $assertion-metadata-map ; additional information about the assertion
*/

Expand Down Expand Up @@ -455,6 +459,12 @@ impl Ingredient {
if self.informational_uri.is_some() {
ingredient_map_len += 1
}
if self.soft_bindings_matched.is_some() {
ingredient_map_len += 1
}
if self.soft_binding_algorithms_matched.is_some() {
ingredient_map_len += 1
}
if self.metadata.is_some() {
ingredient_map_len += 1
}
Expand Down Expand Up @@ -498,6 +508,12 @@ impl Ingredient {
if let Some(info) = &self.informational_uri {
ingredient_map.serialize_field("informationalURI", info)?;
}
if let Some(sbm) = &self.soft_bindings_matched {
ingredient_map.serialize_field("softBindingsMatched", sbm)?;
}
if let Some(sba) = &self.soft_binding_algorithms_matched {
ingredient_map.serialize_field("softBindingAlgorithmsMatched", sba)?;
}
if let Some(md) = &self.metadata {
ingredient_map.serialize_field("metadata", md)?;
}
Expand Down Expand Up @@ -578,7 +594,7 @@ impl AssertionBase for Ingredient {
"metadata",
];

static V3_FIELDS: [&str; 13] = [
static V3_FIELDS: [&str; 15] = [
"dc:title",
"dc:format",
"relationship",
Expand All @@ -591,6 +607,8 @@ impl AssertionBase for Ingredient {
"thumbnail",
"description",
"informationalURI",
"softBindingsMatched",
"softBindingAlgorithmsMatched",
"metadata",
];

Expand Down Expand Up @@ -776,6 +794,10 @@ impl AssertionBase for Ingredient {
map_cbor_to_type("description", &ingredient_value);
let informational_uri: Option<String> =
map_cbor_to_type("informationalURI", &ingredient_value);
let soft_bindings_matched: Option<bool> =
map_cbor_to_type("softBindingsMatched", &ingredient_value);
let soft_binding_algorithms_matched: Option<Vec<String>> =
map_cbor_to_type("softBindingAlgorithmsMatched", &ingredient_value);
let metadata: Option<AssertionMetadata> =
map_cbor_to_type("metadata", &ingredient_value);

Expand All @@ -793,6 +815,8 @@ impl AssertionBase for Ingredient {
data_types,
active_manifest,
claim_signature,
soft_bindings_matched,
soft_binding_algorithms_matched,
version,
..Default::default()
}
Expand Down Expand Up @@ -1001,6 +1025,8 @@ pub mod tests {
validation_results: Some(validation_results.clone()),
active_manifest: Some(HashedUri::new("self#jumbf=c2pa/urn:c2pa:5E7B01FC-4932-4BAB-AB32-D4F12A8AA322".to_owned(), Some("sha256".to_owned()), &[1,2,3,4,5,6,7,8,9,0])),
claim_signature: Some(HashedUri::new("self#jumbf=c2pa/urn:c2pa:5E7B01FC-4932-4BAB-AB32-D4F12A8AA322/c2pa.signature".to_owned(), Some("sha256".to_owned()), &[1,2,3,4,5,6,7,8,9,0])),
soft_bindings_matched: Some(true),
soft_binding_algorithms_matched: Some(vec!["alg1".to_owned(), "alg2".to_owned()]),
version: 1,
};

Expand Down Expand Up @@ -1075,6 +1101,8 @@ pub mod tests {
validation_results: Some(validation_results),
active_manifest: Some(HashedUri::new("self#jumbf=c2pa/urn:c2pa:5E7B01FC-4932-4BAB-AB32-D4F12A8AA322".to_owned(), Some("sha256".to_owned()), &[1,2,3,4,5,6,7,8,9,0])),
claim_signature: Some(HashedUri::new("self#jumbf=c2pa/urn:c2pa:5E7B01FC-4932-4BAB-AB32-D4F12A8AA322/c2pa.signature".to_owned(), Some("sha256".to_owned()), &[1,2,3,4,5,6,7,8,9,0])),
soft_bindings_matched: Some(true),
soft_binding_algorithms_matched: Some(vec!["alg1".to_owned(), "alg2".to_owned()]),
version: 3,
..Default::default()
};
Expand Down