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 b6d075d7d95c547a4baf2d8d7c1b5253eb8e40ee
parent 16f5303bbc7c6e5a4491b56bcf7a6fc71d64adc1
Author: Eric Scouten <scouten@adobe.com>
Date:   Fri,  4 Nov 2022 17:13:33 -0700

Fix new Clippy warnings generated by Rust 1.65 (#151)


Diffstat:
Mmake_test_images/src/main.rs | 2+-
Mmake_test_images/src/make_test_images.rs | 8++++----
Msdk/src/assertions/actions.rs | 2+-
Msdk/src/assertions/creative_work.rs | 2+-
Msdk/src/asset_handlers/bmff_io.rs | 8++++----
Msdk/src/asset_handlers/c2pa_io.rs | 2+-
Msdk/src/claim.rs | 6+++---
Msdk/src/jumbf_io.rs | 2+-
Msdk/src/store.rs | 2+-
9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/make_test_images/src/main.rs b/make_test_images/src/main.rs @@ -25,7 +25,7 @@ fn main() -> Result<()> { } else { "make_test_images/tests.json" }; - let buf = std::fs::read_to_string(&path).context(format!("Reading {}", path))?; + let buf = std::fs::read_to_string(path).context(format!("Reading {}", path))?; let config: make_test_images::Config = serde_json::from_str(&buf).context("Config file format")?; diff --git a/make_test_images/src/make_test_images.rs b/make_test_images/src/make_test_images.rs @@ -225,7 +225,7 @@ impl MakeTestImages { // load the image for editing let mut img = - image::open(&src_path).context(format!("opening parent {:?}", src_path))?; + image::open(src_path).context(format!("opening parent {:?}", src_path))?; // adjust brightness to show we made an edit img = img.brighten(30); @@ -272,7 +272,7 @@ impl MakeTestImages { // get the bits of the ingredient, resize it and overlay it on the base image let img_ingredient = - image::open(&ing_path).context(format!("opening ingredient {:?}", ing_path))?; + image::open(ing_path).context(format!("opening ingredient {:?}", ing_path))?; let img_small = img_ingredient.thumbnail(width, height); image::imageops::overlay(&mut img, &img_small, x, 0); @@ -316,8 +316,8 @@ impl MakeTestImages { let jumbf = jumbf_io::load_jumbf_from_file(&PathBuf::from(src_path)) .context(format!("loading OGP {:?}", src_path))?; // save the edited image to our destination file - let mut img = image::open(&Path::new(src_path)) - .context(format!("loading OGP image{:?}", src_path))?; + let mut img = + image::open(Path::new(src_path)).context(format!("loading OGP image{:?}", src_path))?; img = img.grayscale(); img.save(&dst_path) .context(format!("saving OGP image{:?}", &dst_path))?; diff --git a/sdk/src/assertions/actions.rs b/sdk/src/assertions/actions.rs @@ -357,7 +357,7 @@ pub mod tests { .add_action(make_action1()) .add_action( Action::new("c2pa.filtered") - .set_parameter("name".to_owned(), &"gaussian blur") + .set_parameter("name".to_owned(), "gaussian blur") .unwrap() .set_when("2015-06-26T16:43:23+0200"), ) diff --git a/sdk/src/assertions/creative_work.rs b/sdk/src/assertions/creative_work.rs @@ -63,7 +63,7 @@ impl CreativeWork { } pub fn set_author(self, author: &[SchemaDotOrgPerson]) -> Result<Self> { - self.insert(CW_AUTHOR.to_owned(), &author) + self.insert(CW_AUTHOR.to_owned(), author) } pub fn add_author(self, author: SchemaDotOrgPerson) -> Result<Self> { diff --git a/sdk/src/asset_handlers/bmff_io.rs b/sdk/src/asset_handlers/bmff_io.rs @@ -1053,9 +1053,9 @@ impl AssetIO for BmffIO { } // copy temp file to asset - std::fs::rename(&temp_file.path(), asset_path) + std::fs::rename(temp_file.path(), asset_path) // if rename fails, try to copy in case we are on different volumes - .or_else(|_| std::fs::copy(&temp_file.path(), asset_path).and(Ok(()))) + .or_else(|_| std::fs::copy(temp_file.path(), asset_path).and(Ok(()))) .map_err(Error::IoError) } @@ -1190,9 +1190,9 @@ impl AssetIO for BmffIO { } // copy temp file to asset - std::fs::rename(&temp_file.path(), asset_path) + std::fs::rename(temp_file.path(), asset_path) // if rename fails, try to copy in case we are on different volumes - .or_else(|_| std::fs::copy(&temp_file.path(), asset_path).and(Ok(()))) + .or_else(|_| std::fs::copy(temp_file.path(), asset_path).and(Ok(()))) .map_err(Error::IoError) } } diff --git a/sdk/src/asset_handlers/c2pa_io.rs b/sdk/src/asset_handlers/c2pa_io.rs @@ -42,7 +42,7 @@ impl AssetIO for C2paIO { fn save_cai_store(&self, asset_path: &std::path::Path, store_bytes: &[u8]) -> Result<()> { // just save the data in a file - std::fs::write(asset_path, &store_bytes) + std::fs::write(asset_path, store_bytes) .map_err(|_err| Error::BadParam("C2PA write error".to_owned()))?; Ok(()) diff --git a/sdk/src/claim.rs b/sdk/src/claim.rs @@ -813,7 +813,7 @@ impl Claim { let sig_box_err = match jumbf::labels::manifest_label_from_uri(&claim.signature) { Some(signature_url) if signature_url != claim.label() => true, _ => { - jumbf::labels::box_name_from_uri(&claim.signature).unwrap_or_else(|| "".to_string()) + jumbf::labels::box_name_from_uri(&claim.signature).unwrap_or_default() != jumbf::labels::SIGNATURE } // relative signature box }; @@ -864,7 +864,7 @@ impl Claim { let sig_box_err = match jumbf::labels::manifest_label_from_uri(&claim.signature) { Some(signature_url) if signature_url != claim.label() => true, _ => { - jumbf::labels::box_name_from_uri(&claim.signature).unwrap_or_else(|| "".to_string()) + jumbf::labels::box_name_from_uri(&claim.signature).unwrap_or_default() != jumbf::labels::SIGNATURE } // relative signature box }; @@ -1212,7 +1212,7 @@ impl Claim { for redaction in redactions { if let Some(claim) = ingredient .iter_mut() - .find(|x| redaction.contains(&x.label())) + .find(|x| redaction.contains(x.label())) { claim.redact_assertion(redaction)?; } else { diff --git a/sdk/src/jumbf_io.rs b/sdk/src/jumbf_io.rs @@ -148,7 +148,7 @@ pub fn save_jumbf_to_file(data: &[u8], in_path: &Path, out_path: Option<&Path>) // clone output to be overwritten if in_path != asset_out_path { - fs::copy(&in_path, &asset_out_path).map_err(Error::IoError)?; + fs::copy(in_path, &asset_out_path).map_err(Error::IoError)?; } match get_assetio_handler(&ext) { diff --git a/sdk/src/store.rs b/sdk/src/store.rs @@ -1588,7 +1588,7 @@ impl Store { get_supported_file_extension(asset_path).ok_or(Error::UnsupportedType)?; // verify extensions let ext = get_supported_file_extension(dest_path).ok_or(Error::UnsupportedType)?; if asset_path != dest_path { - fs::copy(&asset_path, &dest_path).map_err(Error::IoError)?; + fs::copy(asset_path, dest_path).map_err(Error::IoError)?; } // update file following the steps outlined in CAI spec