Skip to content

Commit 7990e89

Browse files
committed
error: Move ErrorKind::TooMuchData to aud_io
1 parent dd39f2c commit 7990e89

File tree

13 files changed

+27
-25
lines changed

13 files changed

+27
-25
lines changed

lofty/src/ape/tag/write.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::tag::item::ItemValueRef;
1212
use std::io::{Cursor, Seek, SeekFrom, Write};
1313

1414
use aud_io::io::{FileLike, Truncate};
15+
use aud_io::err as io_err;
1516
use byteorder::{LittleEndian, WriteBytesExt};
1617

1718
#[allow(clippy::shadow_unrelated)]
@@ -205,7 +206,7 @@ where
205206
let size = tag_write.get_ref().len();
206207

207208
if size as u64 + 32 > u64::from(u32::MAX) {
208-
err!(TooMuchData);
209+
io_err!(TooMuchData);
209210
}
210211

211212
let mut footer = [0_u8; 32];

lofty/src/error.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ pub enum ErrorKind {
2424
UnknownFormat,
2525

2626
// File data related errors
27-
/// Attempting to read/write an abnormally large amount of data
28-
TooMuchData,
2927
/// Expected the data to be a different size than provided
3028
///
3129
/// This occurs when the size of an item is written as one value, but that size is either too
@@ -530,10 +528,6 @@ impl Display for LoftyError {
530528
),
531529

532530
// Files
533-
ErrorKind::TooMuchData => write!(
534-
f,
535-
"Attempted to read/write an abnormally large amount of data"
536-
),
537531
ErrorKind::SizeMismatch => write!(
538532
f,
539533
"Encountered an invalid item size, either too big or too small to be valid"

lofty/src/flac/write.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::tag::{Tag, TagType};
1111
use std::borrow::Cow;
1212
use std::io::{Cursor, Read, Seek, SeekFrom, Write};
1313

14+
use aud_io::err as io_err;
1415
use aud_io::io::{FileLike, Length, Truncate};
1516
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
1617

@@ -195,7 +196,7 @@ fn create_comment_block(
195196
let len = (writer.get_ref().len() - 1) as u32;
196197

197198
if len > MAX_BLOCK_SIZE {
198-
err!(TooMuchData);
199+
io_err!(TooMuchData);
199200
}
200201

201202
let comment_end = writer.stream_position()?;
@@ -232,7 +233,7 @@ fn create_picture_blocks(
232233
let pic_len = pic_bytes.len() as u32;
233234

234235
if pic_len > MAX_BLOCK_SIZE {
235-
err!(TooMuchData);
236+
io_err!(TooMuchData);
236237
}
237238

238239
writer.write_all(&pic_len.to_be_bytes()[1..])?;

lofty/src/id3/v2/items/attached_picture_frame.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::picture::{MimeType, Picture, PictureType};
77
use std::borrow::Cow;
88
use std::io::{Read, Write as _};
99

10+
use aud_io::err as io_err;
1011
use aud_io::text::{TextDecodeOptions, TextEncoding, encode_text};
1112
use byteorder::{ReadBytesExt as _, WriteBytesExt as _};
1213

@@ -180,7 +181,7 @@ impl AttachedPictureFrame<'_> {
180181
data.write_all(&self.picture.data)?;
181182

182183
if data.len() as u64 > max_size {
183-
err!(TooMuchData);
184+
io_err!(TooMuchData);
184185
}
185186

186187
Ok(data)

lofty/src/id3/v2/items/sync_text.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::error::{Id3v2Error, Id3v2ErrorKind, Result};
22
use crate::id3::v2::{FrameFlags, FrameHeader, FrameId};
3-
use crate::macros::err;
43

54
use std::borrow::Cow;
65
use std::io::{Cursor, Seek, Write};
@@ -250,7 +249,7 @@ impl SynchronizedTextFrame<'_> {
250249
}
251250

252251
if data.len() as u64 > u64::from(u32::MAX) {
253-
err!(TooMuchData);
252+
io_err!(TooMuchData);
254253
}
255254

256255
return Ok(data);

lofty/src/id3/v2/util/synchsafe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ macro_rules! impl_synchsafe {
243243
};
244244

245245
if self > MAXIMUM_INTEGER {
246-
crate::macros::err!(TooMuchData);
246+
aud_io::err!(TooMuchData);
247247
}
248248

249249
let $n = self;

lofty/src/id3/v2/write/chunk_file.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::macros::err;
55

66
use std::io::{Cursor, Seek, SeekFrom, Write};
77

8+
use aud_io::err as io_err;
89
use aud_io::io::{FileLike, Length, Truncate};
910
use byteorder::{ByteOrder, WriteBytesExt};
1011

@@ -91,7 +92,7 @@ where
9192
}
9293

9394
let Ok(tag_size): std::result::Result<u32, _> = tag_bytes.get_ref().len().try_into() else {
94-
err!(TooMuchData)
95+
io_err!(TooMuchData)
9596
};
9697

9798
let tag_position = actual_stream_size as usize + RIFF_CHUNK_HEADER_SIZE;

lofty/src/iff/aiff/tag.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::config::WriteOptions;
22
use crate::error::{LoftyError, Result};
33
use crate::iff::chunk::Chunks;
4-
use crate::macros::err;
54
use crate::tag::{Accessor, ItemKey, ItemValue, MergeTag, SplitTag, Tag, TagExt, TagItem, TagType};
65

76
use std::borrow::Cow;
87
use std::convert::TryFrom;
98
use std::io::{SeekFrom, Write};
109

10+
use aud_io::err as io_err;
1111
use aud_io::io::{FileLike, Length, Truncate};
1212
use byteorder::BigEndian;
1313
use lofty_attr::tag;
@@ -371,7 +371,7 @@ where
371371
let comt_len = comt.text.len();
372372

373373
if comt_len > u16::MAX as usize {
374-
err!(TooMuchData);
374+
io_err!(TooMuchData);
375375
}
376376

377377
text_chunks.extend((comt_len as u16).to_be_bytes());
@@ -394,7 +394,7 @@ where
394394
i += 1;
395395
}
396396
} else {
397-
err!(TooMuchData);
397+
io_err!(TooMuchData);
398398
}
399399

400400
if (text_chunks.len() - 4) % 2 != 0 {

lofty/src/iff/wav/tag/write.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::macros::err;
77

88
use std::io::{Cursor, Read, Seek, SeekFrom};
99

10+
use aud_io::err as io_err;
1011
use aud_io::io::{FileLike, Length, Truncate};
1112
use byteorder::{LittleEndian, WriteBytesExt};
1213

@@ -154,7 +155,7 @@ pub(super) fn create_riff_info(
154155
let packet_size = Vec::len(bytes) - 4;
155156

156157
if packet_size > u32::MAX as usize {
157-
err!(TooMuchData);
158+
io_err!(TooMuchData);
158159
}
159160

160161
log::debug!("Created RIFF INFO list, size: {} bytes", packet_size);

lofty/src/mp4/ilst/write.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::r#ref::IlstRef;
33
use crate::config::{ParseOptions, WriteOptions};
44
use crate::error::{FileEncodingError, LoftyError, Result};
55
use crate::file::FileType;
6-
use crate::macros::{decode_err, err, try_vec};
6+
use crate::macros::{decode_err, try_vec};
77
use crate::mp4::AtomData;
88
use crate::mp4::atom_info::{ATOM_HEADER_LEN, AtomIdent, AtomInfo, FOURCC_LEN};
99
use crate::mp4::ilst::r#ref::AtomRef;
@@ -13,6 +13,7 @@ use crate::picture::{MimeType, Picture};
1313

1414
use std::io::{Cursor, Seek, SeekFrom, Write};
1515

16+
use aud_io::err as io_err;
1617
use aud_io::io::{FileLike, Length, Truncate};
1718
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
1819
use aud_io::alloc::VecFallibleCapacity;
@@ -298,7 +299,7 @@ fn save_to_existing(
298299

299300
let remaining_space = available_space - ilst_len;
300301
if remaining_space > u64::from(u32::MAX) {
301-
err!(TooMuchData);
302+
io_err!(TooMuchData);
302303
}
303304

304305
let remaining_space = remaining_space as u32;

0 commit comments

Comments
 (0)