Skip to content
Closed
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
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 @@ pub unsafe extern "C" fn c2pa_signer_create(
signed_len_max,
)
};
println!("c_callback: signed_size: {}", signed_size);
println!("c_callback: signed_size: {signed_size}");
if signed_size < 0 {
return Err(c2pa::Error::CoseSignature); // todo:: return errors from callback
}
Expand Down Expand Up @@ -1604,11 +1604,8 @@ mod tests {
#[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 @@ fn load_trust_resource(resource: &TrustResource) -> Result<String> {
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:?}"))?;

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}"))?;

#[cfg(target_os = "wasi")]
let data = blocking_get(&url.to_string())?;
Expand Down Expand Up @@ -376,7 +376,7 @@ fn configure_sdk(args: &CliArgs) -> Result<()> {
{
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:?}");
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 @@ fn configure_sdk(args: &CliArgs) -> Result<()> {

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:?}");
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 @@ fn configure_sdk(args: &CliArgs) -> Result<()> {

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:?}");
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 @@ fn sign_fragmented(
}
}

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 @@ -467,7 +467,7 @@ fn sign_fragmented(
}
}
if count == 0 {
println!("No files matching pattern: {}", ip);
println!("No files matching pattern: {ip}");
}
Ok(())
}
Expand Down Expand Up @@ -499,11 +499,11 @@ fn verify_fragmented(init_pattern: &Path, frag_pattern: &Path) -> Result<Vec<Rea
}
}

println!("Verifying manifest: {:?}", p);
println!("Verifying manifest: {p:?}");
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:?}");
return Ok(readers);
}
}
Expand All @@ -517,7 +517,7 @@ fn verify_fragmented(init_pattern: &Path, frag_pattern: &Path) -> Result<Vec<Rea
}

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

Ok(readers)
Expand Down Expand Up @@ -739,9 +739,9 @@ fn main() -> Result<()> {
let mut reader = Reader::from_file(&output).map_err(special_errs)?;
validate_cawg(&mut reader)?;
if args.detailed {
println!("{:#?}", reader);
println!("{reader:#?}");
} else {
println!("{}", reader)
println!("{reader}")
}
}
} else {
Expand Down Expand Up @@ -775,7 +775,7 @@ fn main() -> Result<()> {
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:#?}");
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 @@ fn main() -> Result<()> {
} else if args.detailed {
let mut reader = Reader::from_file(&args.path).map_err(special_errs)?;
validate_cawg(&mut reader)?;
println!("{:#?}", reader);
println!("{reader:#?}");
} else if let Some(Commands::Fragment {
fragments_glob: Some(fg),
}) = &args.command
Expand All @@ -807,7 +807,7 @@ fn main() -> Result<()> {
} else {
let mut reader = Reader::from_file(&args.path).map_err(special_errs)?;
validate_cawg(&mut reader)?;
println!("{}", reader);
println!("{reader}");
}

Ok(())
Expand Down Expand Up @@ -862,7 +862,7 @@ pub mod tests {
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 @@ fn populate_node(
if let Some(label) = ingredient.active_manifest() {
// create new node
let data = if name_only {
format!("{}_{}", title, label)
format!("{title}_{label}")
} else {
format!("Asset:{}, Manifest:{}", title, label)
format!("Asset:{title}, Manifest:{label}")
};

let new_token = current_token.append(tree, data);
Expand Down Expand Up @@ -83,7 +83,7 @@ pub fn tree<P: AsRef<Path>>(path: P) -> Result<String> {

// 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 c2pa::{settings::Settings, Builder, ManifestDefinition, Reader};
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}");
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"));
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 @@ pub fn compare_folders<P: AsRef<Path>, Q: AsRef<Path>>(folder1: P, folder2: Q) -
if folder1.is_file() && folder2.is_file() {
let issues = compare_image_manifests(folder1, folder2)?;
if !issues.is_empty() {
eprintln!("Failed {:?}", folder1);
eprintln!("Failed {folder1:?}");
for issue in issues {
eprintln!(" {}", issue);
eprintln!(" {issue}");
}
} else {
println!("Passed {:?}", folder1);
println!("Passed {folder1:?}");
}
return Ok(());
} else if !(folder1.is_dir() && folder2.is_dir()) {
Expand Down Expand Up @@ -61,12 +61,12 @@ pub fn compare_folders<P: AsRef<Path>, Q: AsRef<Path>>(folder1: P, folder2: Q) -
));
}
if !issues.is_empty() {
eprintln!("Failed {:?}", relative_path);
eprintln!("Failed {relative_path:?}");
for issue in issues {
eprintln!(" {}", issue);
eprintln!(" {issue}");
}
} else {
println!("Passed {:?}", relative_path);
println!("Passed {relative_path:?}");
}
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ pub fn compare_manifests(
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}"),
&value1,
&value2,
&mut issues,
Expand Down Expand Up @@ -181,18 +181,18 @@ fn compare_json_values(
(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);
}

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}"));
}
}
}
(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);
}
}
(val1, val2) if val1 != val2 => {
Expand Down Expand Up @@ -265,11 +265,11 @@ fn compare_json_values(
}

if val2.is_null() {
issues.push(format!("Missing {}: {}", path, val1));
issues.push(format!("Missing {path}: {val1}"));
} else if val2.is_null() {
issues.push(format!("Added {}: {}", path, val2));
issues.push(format!("Added {path}: {val2}"));
} else {
issues.push(format!("Changed {}: {} vs {}", path, val1, val2));
issues.push(format!("Changed {path}: {val1} vs {val2}"));
}
}
_ => (),
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
3 changes: 1 addition & 2 deletions sdk/src/asset_handlers/gif_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,7 @@ impl ApplicationExtension {
// App block size is a fixed value.
if app_block_size != 0x0b {
return Err(Error::InvalidAsset(format!(
"Invalid block size for app block extension {}!=11",
app_block_size
"Invalid block size for app block extension {app_block_size}!=11"
)));
}

Expand Down
Loading
Loading