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 8f6fe913a80f65996e75d6f28c9901c06feda66b
parent 4d0ad8392e192a2effde7f131500082cd2af62c9
Author: Eric Scouten <scouten@adobe.com>
Date:   Tue,  4 Apr 2023 18:32:12 -0400

Apply code format to doc comments (#220)


Diffstat:
Mmake_test_images/src/main.rs | 1-
Mrustfmt.toml | 1+
Msdk/examples/custom_assertion.rs | 1-
Msdk/src/assertion.rs | 8++++----
Msdk/src/assertions/exif.rs | 2--
Msdk/src/claim.rs | 4++--
Msdk/src/error.rs | 6+++---
Msdk/src/ingredient.rs | 4+---
Msdk/src/jumbf/boxes.rs | 7+++++--
Msdk/src/lib.rs | 14++++++--------
Msdk/src/manifest.rs | 23++++++++++-------------
Msdk/src/manifest_assertion.rs | 10+++++-----
Msdk/src/manifest_store.rs | 6++++--
Msdk/src/openssl/ec_signer.rs | 2+-
Msdk/src/openssl/ed_signer.rs | 2+-
Msdk/src/openssl/rsa_signer.rs | 2+-
Msdk/src/store.rs | 2+-
Msdk/src/utils/hash_utils.rs | 2+-
Msdk/src/validation_status.rs | 2+-
19 files changed, 47 insertions(+), 52 deletions(-)

diff --git a/make_test_images/src/main.rs b/make_test_images/src/main.rs @@ -14,7 +14,6 @@ //! This generates a set of test images with a wide variety of configurations //! To run this, use the following command in a terminal //! cargo run --release --bin make_test_images -//! mod make_test_images; use anyhow::{Context, Result}; diff --git a/rustfmt.toml b/rustfmt.toml @@ -8,6 +8,7 @@ blank_lines_upper_bound = 1 edition = "2018" +format_code_in_doc_comments = true group_imports = "StdExternalCrate" hex_literal_case = "Lower" imports_granularity = "Crate" diff --git a/sdk/examples/custom_assertion.rs b/sdk/examples/custom_assertion.rs @@ -12,7 +12,6 @@ // each license. //! Example: Creating a custom assertion -//! use c2pa::{Assertion, AssertionBase, AssertionCbor, Manifest, Result}; use serde::{Deserialize, Serialize}; diff --git a/sdk/src/assertion.rs b/sdk/src/assertion.rs @@ -208,10 +208,10 @@ impl fmt::Debug for AssertionData { /// Internal Assertion structure /// -// Each assertion type will -// contain its AssertionData. For the User Assertion type we -// allow a String to set the label. The AssertionData contains -// the data payload for the assertion and the version number for its schema (if supported). +/// Each assertion type will +/// contain its AssertionData. For the User Assertion type we +/// allow a String to set the label. The AssertionData contains +/// the data payload for the assertion and the version number for its schema (if supported). #[derive(Clone, Debug, PartialEq, Eq)] pub struct Assertion { label: String, diff --git a/sdk/src/assertions/exif.rs b/sdk/src/assertions/exif.rs @@ -12,7 +12,6 @@ // each license. //! Exif Assertion -//! use std::collections::HashMap; use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -24,7 +23,6 @@ use crate::{assertions::labels, Assertion, AssertionBase, AssertionJson, Error, /// See <https://c2pa.org/specifications/specifications/1.0/specs/C2PA_Specification.html#_exif_information> /// /// This does not yet define or validate individual fields, but will ensure the correct assertion structure -/// #[derive(Serialize, Deserialize, Debug)] pub struct Exif { #[serde(rename = "@context", skip_serializing_if = "Option::is_none")] diff --git a/sdk/src/claim.rs b/sdk/src/claim.rs @@ -247,8 +247,8 @@ pub enum AssertionStoreJsonFormat { pub enum RemoteManifest { NoRemote, // No external manifest (default) SideCar, // Manifest will be saved as a side car file, output asset is untouched. - Remote(String), // Manifest will be saved as a side car file, output asset will contain remote reference - EmbedWithRemote(String), // Manifest will be embedded with a remote reference, sidecar will be generated + Remote(String), /* Manifest will be saved as a side car file, output asset will contain remote reference */ + EmbedWithRemote(String), /* Manifest will be embedded with a remote reference, sidecar will be generated */ } impl Default for RemoteManifest { diff --git a/sdk/src/error.rs b/sdk/src/error.rs @@ -90,9 +90,9 @@ pub enum Error { /// The COSE Sign1 structure can not be parsed. #[error("COSE Sign1 structure can not be parsed: {coset_error}")] InvalidCoseSignature { - coset_error: coset::CoseError, // NOTE: We can not use #[transparent] here because - // coset::CoseError does not implement std::Error::error - // and can't because coset is nostd. + coset_error: coset::CoseError, /* NOTE: We can not use #[transparent] here because + * coset::CoseError does not implement std::Error::error + * and can't because coset is nostd. */ }, /// The COSE signature uses an algorithm that is not supported by this crate. diff --git a/sdk/src/ingredient.rs b/sdk/src/ingredient.rs @@ -131,7 +131,7 @@ impl Ingredient { /// /// ``` /// use c2pa::Ingredient; - /// let ingredient = Ingredient::new("title","image/jpeg","ed610ae51f604002be3dbf0c589a2f1f"); + /// let ingredient = Ingredient::new("title", "image/jpeg", "ed610ae51f604002be3dbf0c589a2f1f"); /// ``` pub fn new<S>(title: S, format: S, instance_id: S) -> Self where @@ -176,7 +176,6 @@ impl Ingredient { } /// Returns thumbnail tuple Some((format, bytes)) or None - /// pub fn thumbnail(&self) -> Option<(&str, Cow<Vec<u8>>)> { self.thumbnail .as_ref() @@ -184,7 +183,6 @@ impl Ingredient { } /// Returns a Cow of thumbnail bytes or Err(Error::NotFound)`. - /// pub fn thumbnail_bytes(&self) -> Result<Cow<Vec<u8>>> { match self.thumbnail.as_ref() { Some(thumbnail) => self.resources.get(&thumbnail.identifier), diff --git a/sdk/src/jumbf/boxes.rs b/sdk/src/jumbf/boxes.rs @@ -2145,7 +2145,7 @@ impl BoxReader { let box_label = jdesc.label(); debug!( "{}", - format!("START#Label: {box_label:?}" /*jdesc.label()*/) + format!("START#Label: {box_label:?}" /* jdesc.label() */) ); let mut sbox = JUMBFSuperBox::from(jdesc); @@ -2223,7 +2223,10 @@ impl BoxReader { } } - debug!("{}", format!("END#Label: {box_label:?}" /*jdesc.label()*/)); + debug!( + "{}", + format!("END#Label: {box_label:?}" /* jdesc.label() */) + ); // return the filled out sbox Ok(sbox) diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs @@ -52,19 +52,17 @@ //! //! ``` //! # use c2pa::Result; -//! use c2pa::{ -//! assertions::User, -//! create_signer, -//! Manifest, -//! SigningAlg, -//! }; -//! //! use std::path::PathBuf; +//! +//! use c2pa::{assertions::User, create_signer, Manifest, SigningAlg}; //! use tempfile::tempdir; //! //! # fn main() -> Result<()> { //! let mut manifest = Manifest::new("my_app".to_owned()); -//! manifest.add_assertion(&User::new("org.contentauth.mylabel", r#"{"my_tag":"Anything I want"}"#))?; +//! manifest.add_assertion(&User::new( +//! "org.contentauth.mylabel", +//! r#"{"my_tag":"Anything I want"}"#, +//! ))?; //! //! let source = PathBuf::from("tests/fixtures/C.jpg"); //! let dir = tempdir()?; diff --git a/sdk/src/manifest.rs b/sdk/src/manifest.rs @@ -153,7 +153,6 @@ impl Manifest { } /// Returns thumbnail tuple with Some((format, bytes)) or None - /// pub fn thumbnail(&self) -> Option<(&str, Cow<Vec<u8>>)> { self.thumbnail .as_ref() @@ -361,8 +360,8 @@ impl Manifest { ///``` /// # use c2pa::Result; /// use c2pa::{ - /// assertions::{Actions, Action, c2pa_action}, - /// Manifest + /// assertions::{c2pa_action, Action, Actions}, + /// Manifest, /// }; /// # fn main() -> Result<()> { /// let mut manifest = Manifest::new("my_app"); @@ -383,8 +382,8 @@ impl Manifest { /// ``` /// # use c2pa::Result; /// use c2pa::{ - /// assertions::{Actions, Action, c2pa_action}, - /// Manifest + /// assertions::{c2pa_action, Action, Actions}, + /// Manifest, /// }; /// # fn main() -> Result<()> { /// let mut manifest = Manifest::new("my_app"); @@ -393,7 +392,7 @@ impl Manifest { /// /// let actions: Actions = manifest.find_assertion(Actions::LABEL)?; /// for action in actions.actions { - /// println!("{}", action.action()); + /// println!("{}", action.action()); /// } /// # Ok(()) /// # } @@ -824,15 +823,13 @@ impl Manifest { /// /// ``` /// # use c2pa::Result; - /// use c2pa::{ - /// assertions::User, - /// create_signer, - /// Manifest, - /// SigningAlg, - /// }; + /// use c2pa::{assertions::User, create_signer, Manifest, SigningAlg}; /// # fn main() -> Result<()> { /// let mut manifest = Manifest::new("my_app".to_owned()); - /// manifest.add_assertion(&User::new("org.contentauth.mylabel", r#"{"my_tag":"Anything I want"}"#))?; + /// manifest.add_assertion(&User::new( + /// "org.contentauth.mylabel", + /// r#"{"my_tag":"Anything I want"}"#, + /// ))?; /// /// let source = "tests/fixtures/C.jpg"; /// let dest = "../target/test_file.jpg"; diff --git a/sdk/src/manifest_assertion.rs b/sdk/src/manifest_assertion.rs @@ -143,8 +143,8 @@ impl ManifestAssertion { ///``` /// # use c2pa::Result; /// use c2pa::{ - /// assertions::{Actions, Action, c2pa_action}, - /// ManifestAssertion + /// assertions::{c2pa_action, Action, Actions}, + /// ManifestAssertion, /// }; /// # fn main() -> Result<()> { /// let actions = Actions::new().add_action(Action::new(c2pa_action::EDITED)); @@ -165,8 +165,8 @@ impl ManifestAssertion { /// ``` /// # use c2pa::Result; /// use c2pa::{ - /// assertions::{Actions, Action, c2pa_action}, - /// ManifestAssertion + /// assertions::{c2pa_action, Action, Actions}, + /// ManifestAssertion, /// }; /// # fn main() -> Result<()> { /// let actions = Actions::new().add_action(Action::new(c2pa_action::EDITED)); @@ -174,7 +174,7 @@ impl ManifestAssertion { /// /// let actions: Actions = manifest_assertion.to_assertion()?; /// for action in actions.actions { - /// println!("{}", action.action()); + /// println!("{}", action.action()); /// } /// # Ok(()) /// # } diff --git a/sdk/src/manifest_store.rs b/sdk/src/manifest_store.rs @@ -26,7 +26,6 @@ use crate::{ #[derive(Serialize)] /// A Container for a set of Manifests and a ValidationStatus list -/// pub struct ManifestStore { #[serde(skip_serializing_if = "Option::is_none")] /// A label for the active (most recent) manifest in the store @@ -184,7 +183,10 @@ impl ManifestStore { /// # use c2pa::Result; /// use c2pa::ManifestStore; /// # fn main() -> Result<()> { - /// let manifest_store = ManifestStore::from_file_with_resources("tests/fixtures/C.jpg","../target/tmp/manifest_store")?; + /// let manifest_store = ManifestStore::from_file_with_resources( + /// "tests/fixtures/C.jpg", + /// "../target/tmp/manifest_store", + /// )?; /// println!("{}", manifest_store); /// # Ok(()) /// # } diff --git a/sdk/src/openssl/ec_signer.rs b/sdk/src/openssl/ec_signer.rs @@ -64,7 +64,7 @@ impl ConfigurableSigner for EcSigner { signcerts, pkey, certs_size, - timestamp_size: 10000, // todo: call out to TSA to get actual timestamp and use that size + timestamp_size: 10000, /* todo: call out to TSA to get actual timestamp and use that size */ alg, tsa_url, }) diff --git a/sdk/src/openssl/ed_signer.rs b/sdk/src/openssl/ed_signer.rs @@ -58,7 +58,7 @@ impl ConfigurableSigner for EdSigner { signcerts, pkey, certs_size, - timestamp_size: 10000, // todo: call out to TSA to get actual timestamp and use that size + timestamp_size: 10000, /* todo: call out to TSA to get actual timestamp and use that size */ alg, tsa_url, }) diff --git a/sdk/src/openssl/rsa_signer.rs b/sdk/src/openssl/rsa_signer.rs @@ -87,7 +87,7 @@ impl ConfigurableSigner for RsaSigner { signcerts, pkey, certs_size: signcert.len(), - timestamp_size: 10000, // todo: call out to TSA to get actual timestamp and use that size + timestamp_size: 10000, /* todo: call out to TSA to get actual timestamp and use that size */ ocsp_size: Cell::new(0), alg, tsa_url, diff --git a/sdk/src/store.rs b/sdk/src/store.rs @@ -674,7 +674,7 @@ impl Store { let mut sigb = CAISignatureBox::new(); let signed_data = match claim.signature_val().is_empty() { false => claim.signature_val().clone(), // existing claims have sig values - true => Store::sign_claim_placeholder(claim, min_reserve_size), // empty is the new sig to be replaced + true => Store::sign_claim_placeholder(claim, min_reserve_size), /* empty is the new sig to be replaced */ }; let sigc = JUMBFCBORContentBox::new(signed_data); diff --git a/sdk/src/utils/hash_utils.rs b/sdk/src/utils/hash_utils.rs @@ -38,7 +38,7 @@ pub struct Exclusion { length: usize, #[serde(skip)] - bmff_offset: Option<u64>, // optional tracking of offset positions to include in BMFF_V2 hashes in BE format + bmff_offset: Option<u64>, /* optional tracking of offset positions to include in BMFF_V2 hashes in BE format */ } impl Exclusion { diff --git a/sdk/src/validation_status.rs b/sdk/src/validation_status.rs @@ -109,7 +109,7 @@ impl ValidationStatus { match error { Error::ClaimMissing { .. } => CLAIM_MISSING, Error::AssertionMissing { .. } => ASSERTION_MISSING, - Error::AssertionDecoding(_code) => ASSERTION_REQUIRED_MISSING, //todo detect json/cbor errors + Error::AssertionDecoding(_code) => ASSERTION_REQUIRED_MISSING, /* todo detect json/cbor errors */ Error::HashMismatch(_) => ASSERTION_DATAHASH_MATCH, Error::RemoteManifestFetch(_) => MANIFEST_INACCESSIBLE, Error::PrereleaseError => STATUS_PRERELEASE,