Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,11 @@ jobs:
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2025-06-05
toolchain: nightly-2025-06-28
components: rustfmt
# Pinning to specific nightly build for now. More recent versions
# introduce a lifetime check that creates a whole slew of build
# errors.

- name: Check format
run: cargo +nightly-2025-06-05 fmt --all -- --check
run: cargo +nightly-2025-06-28 fmt --all -- --check

docs_rs:
name: Preflight docs.rs build
Expand Down
8 changes: 4 additions & 4 deletions c2pa_c_ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() {

// Get the workspace target directory.
let out_dir = env::var("OUT_DIR").expect("OUT_DIR environment variable not set");
println!("Running c2pa_c_ffi folder build script: {:?}", out_dir);
println!("Running c2pa_c_ffi folder build script: {out_dir:?}");

let workspace_target_dir = Path::new(&out_dir)
.ancestors()
Expand All @@ -38,10 +38,10 @@ fn main() {
// Add a version string to the header.
config.header = match config.header {
Some(ref mut header) => {
header.push_str(&format!("\n// Version: {}\n", version));
header.push_str(&format!("\n// Version: {version}\n"));
Some(header.clone())
}
None => Some(format!("\n// Version: {}\n", version)),
None => Some(format!("\n// Version: {version}\n")),
};

// Generate the header file.
Expand All @@ -50,7 +50,7 @@ fn main() {
cbindgen::Error::ParseSyntaxError { .. } => {
eprintln!("Warning: ParseSyntaxError encountered while generating bindings");
}
e => panic!("{:?}", e),
e => panic!("{e:?}"),
},
|bindings| {
println!(
Expand Down
9 changes: 3 additions & 6 deletions c2pa_c_ffi/src/c_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@
signed_len_max,
)
};
println!("c_callback: signed_size: {}", signed_size);
println!("c_callback: signed_size: {signed_size}");

Check warning on line 1121 in c2pa_c_ffi/src/c_api.rs

View check run for this annotation

Codecov / codecov/patch

c2pa_c_ffi/src/c_api.rs#L1121

Added line #L1121 was not covered by tests
if signed_size < 0 {
return Err(c2pa::Error::CoseSignature); // todo:: return errors from callback
}
Expand Down Expand Up @@ -1604,11 +1604,8 @@
#[cfg(feature = "file_io")]
fn test_reader_from_file_cawg_identity() {
let base = env!("CARGO_MANIFEST_DIR");
let path = CString::new(format!(
"{}/../sdk/tests/fixtures/C_with_CAWG_data.jpg",
base
))
.unwrap();
let path =
CString::new(format!("{base}/../sdk/tests/fixtures/C_with_CAWG_data.jpg")).unwrap();
let reader = unsafe { c2pa_reader_from_file(path.as_ptr()) };
if reader.is_null() {
let error = unsafe { c2pa_error() };
Expand Down
8 changes: 4 additions & 4 deletions c2pa_c_ffi/src/json_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ mod tests {
/// returns a path to a file in the fixtures folder
pub fn test_path(path: &str) -> String {
let base = env!("CARGO_MANIFEST_DIR");
format!("{}/../sdk/{}", base, path)
format!("{base}/../sdk/{path}")
}

#[test]
Expand All @@ -92,7 +92,7 @@ mod tests {
let result = read_file(&path, None);
assert!(result.is_ok());
let json_report = result.unwrap();
println!("{}", json_report);
println!("{json_report}");
assert!(json_report.contains("C.jpg"));
assert!(!json_report.contains("validation_status"));
}
Expand All @@ -107,7 +107,7 @@ mod tests {
let result = read_file(&path, Some(data_dir.to_owned()));
//assert!(result.is_ok());
let json_report = result.unwrap();
println!("{}", json_report);
println!("{json_report}");
assert!(json_report.contains("C.jpg"));
assert!(PathBuf::from(data_dir).exists());
assert!(json_report.contains("thumbnail"));
Expand All @@ -119,7 +119,7 @@ mod tests {
let result = read_file(&path, None);
assert!(result.is_ok());
let json_report = result.unwrap();
println!("{}", json_report);
println!("{json_report}");
assert!(json_report.contains("cawg.identity"));
assert!(json_report.contains("cawg.ica.credential_valid"));
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/callback_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<'a> CallbackSigner<'a> {
impl Signer for CallbackSigner<'_> {
fn sign(&self, data: &[u8]) -> c2pa::Result<Vec<u8>> {
self.callback.sign(data).map_err(|e| {
eprintln!("Unable to embed signature into asset. {}", e);
eprintln!("Unable to embed signature into asset. {e}");
Error::EmbeddingError
})
}
Expand Down
32 changes: 16 additions & 16 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@
match resource {
TrustResource::File(path) => {
let data = std::fs::read_to_string(path)
.with_context(|| format!("Failed to read trust resource from path: {:?}", path))?;
.with_context(|| format!("Failed to read trust resource from path: {path:?}"))?;

Check warning on line 256 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L256

Added line #L256 was not covered by tests

Ok(data)
}
TrustResource::Url(url) => {
#[cfg(not(target_os = "wasi"))]
let data = reqwest::blocking::get(url.to_string())?
.text()
.with_context(|| format!("Failed to read trust resource from URL: {}", url))?;
.with_context(|| format!("Failed to read trust resource from URL: {url}"))?;

Check warning on line 264 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L264

Added line #L264 was not covered by tests

#[cfg(target_os = "wasi")]
let data = blocking_get(&url.to_string())?;
Expand Down Expand Up @@ -376,7 +376,7 @@
{
if let Some(trust_list) = &trust_anchors {
let data = load_trust_resource(trust_list)?;
debug!("Using trust anchors from {:?}", trust_list);
debug!("Using trust anchors from {trust_list:?}");

Check warning on line 379 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L379

Added line #L379 was not covered by tests
let replacement_val = serde_json::Value::String(data).to_string(); // escape string
let setting = TA.replace("replacement_val", &replacement_val);

Expand All @@ -387,7 +387,7 @@

if let Some(allowed_list) = &allowed_list {
let data = load_trust_resource(allowed_list)?;
debug!("Using allowed list from {:?}", allowed_list);
debug!("Using allowed list from {allowed_list:?}");

Check warning on line 390 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L390

Added line #L390 was not covered by tests
let replacement_val = serde_json::Value::String(data).to_string(); // escape string
let setting = AL.replace("replacement_val", &replacement_val);

Expand All @@ -398,7 +398,7 @@

if let Some(trust_config) = &trust_config {
let data = load_trust_resource(trust_config)?;
debug!("Using trust config from {:?}", trust_config);
debug!("Using trust config from {trust_config:?}");

Check warning on line 401 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L401

Added line #L401 was not covered by tests
let replacement_val = serde_json::Value::String(data).to_string(); // escape string
let setting = TC.replace("replacement_val", &replacement_val);

Expand Down Expand Up @@ -456,7 +456,7 @@
}
}

println!("Adding manifest to: {:?}", p);
println!("Adding manifest to: {p:?}");

Check warning on line 459 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L459

Added line #L459 was not covered by tests
let new_output_path =
output_path.join(init_dir.file_name().context("invalid file name")?);
builder.sign_fragmented_files(signer, &p, &fragments, &new_output_path)?;
Expand All @@ -467,7 +467,7 @@
}
}
if count == 0 {
println!("No files matching pattern: {}", ip);
println!("No files matching pattern: {ip}");

Check warning on line 470 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L470

Added line #L470 was not covered by tests
}
Ok(())
}
Expand Down Expand Up @@ -499,11 +499,11 @@
}
}

println!("Verifying manifest: {:?}", p);
println!("Verifying manifest: {p:?}");

Check warning on line 502 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L502

Added line #L502 was not covered by tests
let reader = Reader::from_fragmented_files(p, &fragments)?;
if let Some(vs) = reader.validation_status() {
if let Some(e) = vs.iter().find(|v| !v.passed()) {
eprintln!("Error validating segments: {:?}", e);
eprintln!("Error validating segments: {e:?}");

Check warning on line 506 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L506

Added line #L506 was not covered by tests
return Ok(readers);
}
}
Expand All @@ -517,7 +517,7 @@
}

if count == 0 {
println!("No files matching pattern: {}", ip);
println!("No files matching pattern: {ip}");

Check warning on line 520 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L520

Added line #L520 was not covered by tests
}

Ok(readers)
Expand Down Expand Up @@ -739,9 +739,9 @@
let mut reader = Reader::from_file(&output).map_err(special_errs)?;
validate_cawg(&mut reader)?;
if args.detailed {
println!("{:#?}", reader);
println!("{reader:#?}");

Check warning on line 742 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L742

Added line #L742 was not covered by tests
} else {
println!("{}", reader)
println!("{reader}")

Check warning on line 744 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L744

Added line #L744 was not covered by tests
}
}
} else {
Expand Down Expand Up @@ -775,7 +775,7 @@
if args.detailed {
// for a detailed report first call the above to generate the thumbnails
// then call this to add the detailed report
let detailed = format!("{:#?}", reader);
let detailed = format!("{reader:#?}");

Check warning on line 778 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L778

Added line #L778 was not covered by tests
File::create(output.join("detailed.json"))?.write_all(&detailed.into_bytes())?;
}
File::create(output.join("manifest_store.json"))?.write_all(&report.into_bytes())?;
Expand All @@ -789,7 +789,7 @@
} else if args.detailed {
let mut reader = Reader::from_file(&args.path).map_err(special_errs)?;
validate_cawg(&mut reader)?;
println!("{:#?}", reader);
println!("{reader:#?}");

Check warning on line 792 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L792

Added line #L792 was not covered by tests
} else if let Some(Commands::Fragment {
fragments_glob: Some(fg),
}) = &args.command
Expand All @@ -807,7 +807,7 @@
} else {
let mut reader = Reader::from_file(&args.path).map_err(special_errs)?;
validate_cawg(&mut reader)?;
println!("{}", reader);
println!("{reader}");

Check warning on line 810 in cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/main.rs#L810

Added line #L810 was not covered by tests
}

Ok(())
Expand Down Expand Up @@ -862,7 +862,7 @@
let ms = Reader::from_file(output_path)
.expect("from_file")
.to_string();
println!("{}", ms);
println!("{ms}");
//let ms = report_from_path(&OUTPUT_PATH, false).expect("report_from_path");
assert!(ms.contains("my_key"));
}
Expand Down
6 changes: 3 additions & 3 deletions cli/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
if let Some(label) = ingredient.active_manifest() {
// create new node
let data = if name_only {
format!("{}_{}", title, label)
format!("{title}_{label}")

Check warning on line 37 in cli/src/tree.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/tree.rs#L37

Added line #L37 was not covered by tests
} else {
format!("Asset:{}, Manifest:{}", title, label)
format!("Asset:{title}, Manifest:{label}")

Check warning on line 39 in cli/src/tree.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/tree.rs#L39

Added line #L39 was not covered by tests
};

let new_token = current_token.append(tree, data);
Expand Down Expand Up @@ -83,7 +83,7 @@

// walk through the manifests and show the contents
Ok(if let Some(manifest_label) = reader.active_label() {
let data = format!("Asset:{}, Manifest:{}", asset_name, manifest_label);
let data = format!("Asset:{asset_name}, Manifest:{manifest_label}");
let (mut tree, root_token) = Arena::with_data(data);
populate_node(&mut tree, &reader, manifest_label, &root_token, false)?;
// print tree
Expand Down
4 changes: 2 additions & 2 deletions export_schema/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use schemars::{schema::RootSchema, schema_for};

fn write_schema(schema: &RootSchema, name: &str) {
println!("Exporting JSON schema for {}", name);
println!("Exporting JSON schema for {name}");

Check warning on line 8 in export_schema/src/main.rs

View check run for this annotation

Codecov / codecov/patch

export_schema/src/main.rs#L8

Added line #L8 was not covered by tests
let output = serde_json::to_string_pretty(schema).expect("Failed to serialize schema");
let output_dir = Path::new("./target/schema");
fs::create_dir_all(output_dir).expect("Could not create schema directory");
let output_path = output_dir.join(format!("{}.schema.json", name));
let output_path = output_dir.join(format!("{name}.schema.json"));

Check warning on line 12 in export_schema/src/main.rs

View check run for this annotation

Codecov / codecov/patch

export_schema/src/main.rs#L12

Added line #L12 was not covered by tests
fs::write(&output_path, output).expect("Unable to write schema");
println!("Wrote schema to {}", output_path.display());
}
Expand Down
26 changes: 13 additions & 13 deletions make_test_images/src/compare_manifests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
if folder1.is_file() && folder2.is_file() {
let issues = compare_image_manifests(folder1, folder2)?;
if !issues.is_empty() {
eprintln!("Failed {:?}", folder1);
eprintln!("Failed {folder1:?}");

Check warning on line 30 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L30

Added line #L30 was not covered by tests
for issue in issues {
eprintln!(" {}", issue);
eprintln!(" {issue}");

Check warning on line 32 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L32

Added line #L32 was not covered by tests
}
} else {
println!("Passed {:?}", folder1);
println!("Passed {folder1:?}");

Check warning on line 35 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L35

Added line #L35 was not covered by tests
}
return Ok(());
} else if !(folder1.is_dir() && folder2.is_dir()) {
Expand Down Expand Up @@ -61,12 +61,12 @@
));
}
if !issues.is_empty() {
eprintln!("Failed {:?}", relative_path);
eprintln!("Failed {relative_path:?}");

Check warning on line 64 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L64

Added line #L64 was not covered by tests
for issue in issues {
eprintln!(" {}", issue);
eprintln!(" {issue}");

Check warning on line 66 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L66

Added line #L66 was not covered by tests
}
} else {
println!("Passed {:?}", relative_path);
println!("Passed {relative_path:?}");

Check warning on line 69 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L69

Added line #L69 was not covered by tests
}
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@
let value1 = serde_json::to_value(manifest_store1.get_manifest(label1))?;
let value2 = serde_json::to_value(manifest_store2.get_manifest(label2))?;
compare_json_values(
&format!("manifests.{}", label1),
&format!("manifests.{label1}"),

Check warning on line 129 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L129

Added line #L129 was not covered by tests
&value1,
&value2,
&mut issues,
Expand Down Expand Up @@ -181,18 +181,18 @@
(serde_json::Value::Object(map1), serde_json::Value::Object(map2)) => {
for (key, val1) in map1 {
let val2 = map2.get(key).unwrap_or(&serde_json::Value::Null);
compare_json_values(&format!("{}.{}", path, key), val1, val2, issues);
compare_json_values(&format!("{path}.{key}"), val1, val2, issues);

Check warning on line 184 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L184

Added line #L184 was not covered by tests
}

for (key, value) in map2 {
if map1.get(key).is_none() {
issues.push(format!("Added {}.{}: {}", path, key, value));
issues.push(format!("Added {path}.{key}: {value}"));

Check warning on line 189 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L189

Added line #L189 was not covered by tests
}
}
}
(serde_json::Value::Array(arr1), serde_json::Value::Array(arr2)) => {
for (i, (val1, val2)) in arr1.iter().zip(arr2.iter()).enumerate() {
compare_json_values(&format!("{}[{}]", path, i), val1, val2, issues);
compare_json_values(&format!("{path}[{i}]"), val1, val2, issues);

Check warning on line 195 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L195

Added line #L195 was not covered by tests
}
}
(val1, val2) if val1 != val2 => {
Expand Down Expand Up @@ -265,11 +265,11 @@
}

if val2.is_null() {
issues.push(format!("Missing {}: {}", path, val1));
issues.push(format!("Missing {path}: {val1}"));

Check warning on line 268 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L268

Added line #L268 was not covered by tests
} else if val2.is_null() {
issues.push(format!("Added {}: {}", path, val2));
issues.push(format!("Added {path}: {val2}"));

Check warning on line 270 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L270

Added line #L270 was not covered by tests
} else {
issues.push(format!("Changed {}: {} vs {}", path, val1, val2));
issues.push(format!("Changed {path}: {val1} vs {val2}"));

Check warning on line 272 in make_test_images/src/compare_manifests.rs

View check run for this annotation

Codecov / codecov/patch

make_test_images/src/compare_manifests.rs#L272

Added line #L272 was not covered by tests
}
}
_ => (),
Expand Down
4 changes: 2 additions & 2 deletions sdk/examples/fragmented_bmff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mod cawg {
}
}

println!("Adding manifest to: {:?}", p);
println!("Adding manifest to: {p:?}");
let new_output_path =
output_path.join(init_dir.file_name().context("invalid file name")?);
builder.sign_fragmented_files(signer, &p, &fragments, &new_output_path)?;
Expand All @@ -165,7 +165,7 @@ mod cawg {
}
}
if count == 0 {
println!("No files matching pattern: {}", ip);
println!("No files matching pattern: {ip}");
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/examples/v2show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() -> Result<()> {
let reader = match Reader::from_stream(&format, &mut file) {
Ok(reader) => Ok(reader),
Err(Error::RemoteManifestUrl(url)) => {
println!("Fetching remote manifest from {}", url);
println!("Fetching remote manifest from {url}");
let mut c2pa_data = Vec::new();
let resp = ureq::get(&url).call()?;
resp.into_reader().read_to_end(&mut c2pa_data)?;
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/asset_handlers/bmff_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ pub(crate) fn build_bmff_tree<R: Read + Seek + ?Sized>(
while current < end {
// Get box header.
let header = BoxHeaderLite::read(reader)
.map_err(|err| Error::InvalidAsset(format!("Bad BMFF {}", err)))?;
.map_err(|err| Error::InvalidAsset(format!("Bad BMFF {err}")))?;

// Break if size zero BoxHeader
let s = header.size;
Expand Down
Loading
Loading