Skip to content

Commit 10c48a9

Browse files
fix: Remove unmaintained dependencies conv and custom_derive (#1393)
1 parent aae8b05 commit 10c48a9

File tree

9 files changed

+64
-93
lines changed

9 files changed

+64
-93
lines changed

Cargo.lock

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ config = { version = "0.14.0", default-features = false, features = [
106106
] }
107107
const-hex = "1.14"
108108
const-oid = { version = "0.9.6", optional = true }
109-
conv = "0.3.3"
110109
coset = "0.3.8"
111110
extfmt = "0.1.1"
112111
der = { version = "0.7.9", optional = true }

sdk/src/asset_handlers/bmff_io.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use std::{
2121

2222
use atree::{Arena, Token};
2323
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
24-
use conv::ValueFrom;
2524

2625
use crate::{
2726
assertions::{BmffMerkleMap, ExclusionsMap},
@@ -1591,16 +1590,16 @@ impl CAIWriter for BmffIO {
15911590
let new_c2pa_box_size = new_c2pa_box.len();
15921591

15931592
let (start, end) = if let Some(c2pa_length) = c2pa_length {
1594-
let start = usize::value_from(c2pa_start)
1593+
let start = usize::try_from(c2pa_start)
15951594
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?; // get beginning of chunk which starts 4 bytes before label
15961595

1597-
let end = usize::value_from(c2pa_start + c2pa_length)
1596+
let end = usize::try_from(c2pa_start + c2pa_length)
15981597
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?;
15991598

16001599
(start, end)
16011600
} else {
16021601
// insert new c2pa
1603-
let end = usize::value_from(c2pa_start)
1602+
let end = usize::try_from(c2pa_start)
16041603
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?;
16051604

16061605
(end, end)
@@ -1733,10 +1732,10 @@ impl CAIWriter for BmffIO {
17331732
};
17341733

17351734
let (start, end) = if let Some(c2pa_length) = c2pa_length {
1736-
let start = usize::value_from(c2pa_start)
1735+
let start = usize::try_from(c2pa_start)
17371736
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?; // get beginning of chunk which starts 4 bytes before label
17381737

1739-
let end = usize::value_from(c2pa_start + c2pa_length)
1738+
let end = usize::try_from(c2pa_start + c2pa_length)
17401739
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?;
17411740

17421741
(start, end)
@@ -1969,16 +1968,16 @@ impl RemoteRefEmbed for BmffIO {
19691968
let new_xmp_box_size = new_xmp_box.len();
19701969

19711970
let (start, end) = if let Some(xmp_length) = xmp_length {
1972-
let start = usize::value_from(xmp_start)
1971+
let start = usize::try_from(xmp_start)
19731972
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?; // get beginning of chunk which starts 4 bytes before label
19741973

1975-
let end = usize::value_from(xmp_start + xmp_length)
1974+
let end = usize::try_from(xmp_start + xmp_length)
19761975
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?;
19771976

19781977
(start, end)
19791978
} else {
19801979
// insert new c2pa
1981-
let end = usize::value_from(xmp_start)
1980+
let end = usize::try_from(xmp_start)
19821981
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?;
19831982

19841983
(end, end)

sdk/src/asset_handlers/mp3_io.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use std::{
1818
};
1919

2020
use byteorder::{BigEndian, ReadBytesExt};
21-
use conv::ValueFrom;
2221
use id3::{
2322
frame::{EncapsulatedObject, Private},
2423
*,
@@ -432,31 +431,31 @@ impl CAIWriter for Mp3IO {
432431
get_manifest_pos(&mut output_stream).ok_or(Error::EmbeddingError)?;
433432

434433
positions.push(HashObjectPositions {
435-
offset: usize::value_from(manifest_pos)
434+
offset: usize::try_from(manifest_pos)
436435
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?,
437-
length: usize::value_from(manifest_len)
436+
length: usize::try_from(manifest_len)
438437
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?,
439438
htype: HashBlockObjectType::Cai,
440439
});
441440

442441
// add hash of chunks before cai
443442
positions.push(HashObjectPositions {
444443
offset: 0,
445-
length: usize::value_from(manifest_pos)
444+
length: usize::try_from(manifest_pos)
446445
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?,
447446
htype: HashBlockObjectType::Other,
448447
});
449448

450449
// add position from cai to end
451-
let end = u64::value_from(manifest_pos)
452-
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?
453-
+ u64::value_from(manifest_len)
454-
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?;
450+
let Some(end) = u64::checked_add(manifest_pos, manifest_len as u64) else {
451+
return Err(Error::InvalidAsset("value out of range".to_string()));
452+
};
453+
455454
let file_end = stream_len(&mut output_stream)?;
456455
positions.push(HashObjectPositions {
457-
offset: usize::value_from(end)
456+
offset: usize::try_from(end)
458457
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?, // len of cai
459-
length: usize::value_from(file_end - end)
458+
length: usize::try_from(file_end - end)
460459
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?,
461460
htype: HashBlockObjectType::Other,
462461
});

sdk/src/asset_handlers/png_io.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use std::{
1818
};
1919

2020
use byteorder::{BigEndian, ReadBytesExt};
21-
use conv::ValueFrom;
2221
use png_pong::chunk::InternationalText;
2322
use serde_bytes::ByteBuf;
2423

@@ -339,10 +338,10 @@ impl CAIWriter for PngIO {
339338
let mut iter = ps.into_iter();
340339
if let Some(existing_cai_data) = iter.find(|png_cp| png_cp.name == CAI_CHUNK) {
341340
// replace existing CAI data
342-
let cai_start = usize::value_from(existing_cai_data.start)
341+
let cai_start = usize::try_from(existing_cai_data.start)
343342
.map_err(|_err| Error::InvalidAsset("value out of range".to_owned()))?; // get beginning of chunk which starts 4 bytes before label
344343

345-
let cai_end = usize::value_from(existing_cai_data.end())
344+
let cai_end = usize::try_from(existing_cai_data.end())
346345
.map_err(|_err| Error::InvalidAsset("value out of range".to_owned()))?;
347346

348347
png_buf.splice(cai_start..cai_end, empty_buf.iter().cloned());
@@ -356,7 +355,7 @@ impl CAIWriter for PngIO {
356355

357356
// add new cai data after the image header chunk
358357
if let Some(img_hdr) = iter.find(|png_cp| png_cp.name == IMG_HDR) {
359-
let img_hdr_end = usize::value_from(img_hdr.end())
358+
let img_hdr_end = usize::try_from(img_hdr.end())
360359
.map_err(|_err| Error::InvalidAsset("value out of range".to_owned()))?;
361360

362361
png_buf.splice(img_hdr_end..img_hdr_end, cai_data.iter().cloned());
@@ -450,10 +449,10 @@ impl CAIWriter for PngIO {
450449
let mut iter = ps.into_iter();
451450
if let Some(existing_cai) = iter.find(|pcp| pcp.name == CAI_CHUNK) {
452451
// replace existing CAI
453-
let start = usize::value_from(existing_cai.start)
452+
let start = usize::try_from(existing_cai.start)
454453
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?; // get beginning of chunk which starts 4 bytes before label
455454

456-
let end = usize::value_from(existing_cai.end())
455+
let end = usize::try_from(existing_cai.end())
457456
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?;
458457

459458
png_buf.splice(start..end, empty_buf.iter().cloned());
@@ -521,10 +520,10 @@ impl AssetIO for PngIO {
521520
let mut iter = ps.into_iter();
522521
if let Some(existing_cai) = iter.find(|pcp| pcp.name == CAI_CHUNK) {
523522
// replace existing CAI
524-
let start = usize::value_from(existing_cai.start)
523+
let start = usize::try_from(existing_cai.start)
525524
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?; // get beginning of chunk which starts 4 bytes before label
526525

527-
let end = usize::value_from(existing_cai.end())
526+
let end = usize::try_from(existing_cai.end())
528527
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?;
529528

530529
png_buf.splice(start..end, empty_buf.iter().cloned());
@@ -686,10 +685,10 @@ impl RemoteRefEmbed for PngIO {
686685
.map_err(Error::IoError)?;
687686

688687
// replace existing XMP
689-
let xmp_start = usize::value_from(start)
688+
let xmp_start = usize::try_from(start)
690689
.map_err(|_err| Error::InvalidAsset("value out of range".to_owned()))?; // get beginning of chunk which starts 4 bytes before label
691690

692-
let xmp_end = usize::value_from(start + xmp_len as u64)
691+
let xmp_end = usize::try_from(start + xmp_len as u64)
693692
.map_err(|_err| Error::InvalidAsset("value out of range".to_owned()))?;
694693

695694
png_buf.splice(xmp_start..xmp_end, xmp_data.iter().cloned());

sdk/src/asset_handlers/riff_io.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use std::{
1919
};
2020

2121
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
22-
use conv::ValueFrom;
2322
use riff::*;
2423

2524
use crate::{
@@ -446,31 +445,31 @@ impl CAIWriter for RiffIO {
446445
get_manifest_pos(&mut output_stream).ok_or(Error::EmbeddingError)?;
447446

448447
positions.push(HashObjectPositions {
449-
offset: usize::value_from(manifest_pos)
448+
offset: usize::try_from(manifest_pos)
450449
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?,
451-
length: usize::value_from(manifest_len)
450+
length: usize::try_from(manifest_len)
452451
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?,
453452
htype: HashBlockObjectType::Cai,
454453
});
455454

456455
// add hash of chunks before cai
457456
positions.push(HashObjectPositions {
458457
offset: 0,
459-
length: usize::value_from(manifest_pos)
458+
length: usize::try_from(manifest_pos)
460459
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?,
461460
htype: HashBlockObjectType::Other,
462461
});
463462

464463
// add position from cai to end
465-
let end = u64::value_from(manifest_pos)
466-
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?
467-
+ u64::value_from(manifest_len)
468-
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?;
464+
let Some(end) = u64::checked_add(manifest_pos, manifest_len as u64) else {
465+
return Err(Error::InvalidAsset("value out of range".to_string()));
466+
};
467+
469468
let file_end = stream_len(&mut output_stream)?;
470469
positions.push(HashObjectPositions {
471-
offset: usize::value_from(end)
470+
offset: usize::try_from(end)
472471
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?, // len of cai
473-
length: usize::value_from(file_end - end)
472+
length: usize::try_from(file_end - end)
474473
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?,
475474
htype: HashBlockObjectType::Other,
476475
});

sdk/src/asset_handlers/svg_io.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use std::{
1818
path::Path,
1919
};
2020

21-
use conv::ValueFrom;
2221
use quick_xml::{
2322
events::{BytesText, Event},
2423
Reader, Writer,
@@ -546,7 +545,7 @@ impl CAIWriter for SvgIO {
546545

547546
// add position from cai to end
548547
let end = manifest_pos + encoded_manifest_len;
549-
let length = usize::value_from(stream_len(input_stream)?)
548+
let length = usize::try_from(stream_len(input_stream)?)
550549
.map_err(|_err| Error::InvalidAsset("value out of range".to_string()))?
551550
.saturating_sub(end);
552551
positions.push(HashObjectPositions {

0 commit comments

Comments
 (0)