mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-10 06:34:18 +00:00
Clippy: fix explicit_auto_deref
This commit is contained in:
parent
22b84cb2be
commit
39477efe17
26 changed files with 54 additions and 54 deletions
|
@ -191,7 +191,7 @@ impl Page {
|
|||
///
|
||||
/// See [`Page::as_bytes`]
|
||||
pub fn gen_crc(&mut self) -> Result<()> {
|
||||
self.checksum = crc::crc32(&*self.as_bytes()?);
|
||||
self.checksum = crc::crc32(&self.as_bytes()?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ impl Page {
|
|||
/// let comment_header_packet = vec![...];
|
||||
/// let stream_serial_number = 2784419176;
|
||||
///
|
||||
/// let pages = paginate(&*comment_header_packet, stream_serial_number, 0, 0);
|
||||
/// let pages = paginate(&comment_header_packet, stream_serial_number, 0, 0);
|
||||
/// ```
|
||||
pub fn paginate(packet: &[u8], stream_serial: u32, abgp: u64, flags: u8) -> Vec<Page> {
|
||||
let mut pages = Vec::new();
|
||||
|
@ -411,7 +411,7 @@ mod tests {
|
|||
fn paginate_large() {
|
||||
let packet = std::fs::read("test_assets/large_comment_packet.page").unwrap();
|
||||
|
||||
let pages = paginate(&*packet, 1234, 0, 0);
|
||||
let pages = paginate(&packet, 1234, 0, 0);
|
||||
|
||||
let len = pages.len();
|
||||
|
||||
|
|
|
@ -364,7 +364,7 @@ where
|
|||
|
||||
pub(crate) fn dump_to<W: Write>(&mut self, writer: &mut W) -> Result<()> {
|
||||
let temp = write::create_ape_tag(self)?;
|
||||
writer.write_all(&*temp)?;
|
||||
writer.write_all(&temp)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ where
|
|||
|
||||
data.rewind()?;
|
||||
data.set_len(0)?;
|
||||
data.write_all(&*file_bytes)?;
|
||||
data.write_all(&file_bytes)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ where
|
|||
#[cfg(feature = "vorbis_comments")]
|
||||
6 => tag
|
||||
.pictures
|
||||
.push(Picture::from_flac_bytes(&*block.content, false)?),
|
||||
.push(Picture::from_flac_bytes(&block.content, false)?),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ where
|
|||
|
||||
data.seek(SeekFrom::Start(stream_info_end as u64))?;
|
||||
data.set_len(stream_info_end as u64)?;
|
||||
data.write_all(&*file_bytes)?;
|
||||
data.write_all(&file_bytes)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ impl<'a> Id3v1TagRef<'a> {
|
|||
|
||||
pub(crate) fn dump_to<W: Write>(&mut self, writer: &mut W) -> Result<()> {
|
||||
let temp = super::write::encode(self)?;
|
||||
writer.write_all(&*temp)?;
|
||||
writer.write_all(&temp)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -64,19 +64,19 @@ pub(super) fn encode(tag: &Id3v1TagRef<'_>) -> std::io::Result<Vec<u8>> {
|
|||
writer.write_all(&[b'T', b'A', b'G'])?;
|
||||
|
||||
let title = resize_string(tag.title, 30)?;
|
||||
writer.write_all(&*title)?;
|
||||
writer.write_all(&title)?;
|
||||
|
||||
let artist = resize_string(tag.artist, 30)?;
|
||||
writer.write_all(&*artist)?;
|
||||
writer.write_all(&artist)?;
|
||||
|
||||
let album = resize_string(tag.album, 30)?;
|
||||
writer.write_all(&*album)?;
|
||||
writer.write_all(&album)?;
|
||||
|
||||
let year = resize_string(tag.year, 4)?;
|
||||
writer.write_all(&*year)?;
|
||||
writer.write_all(&year)?;
|
||||
|
||||
let comment = resize_string(tag.comment, 28)?;
|
||||
writer.write_all(&*comment)?;
|
||||
writer.write_all(&comment)?;
|
||||
|
||||
writer.write_u8(0)?;
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ fn parse_user_defined(
|
|||
frame_content = decode_text(content, encoding, false)?.unwrap_or_default();
|
||||
} else {
|
||||
frame_content = match read_to_terminator(content, TextEncoding::UTF16) {
|
||||
Some(raw_text) => utf16_decode(&*raw_text, endianness).map_err(|_| {
|
||||
Some(raw_text) => utf16_decode(&raw_text, endianness).map_err(|_| {
|
||||
Into::<LoftyError>::into(ID3v2Error::new(ID3v2ErrorKind::BadSyncText))
|
||||
})?,
|
||||
None => String::new(),
|
||||
|
|
|
@ -107,7 +107,7 @@ mod tests {
|
|||
|
||||
let cont = crate::tag::utils::test_utils::read_path("tests/tags/assets/id3v2/test.geob");
|
||||
|
||||
let parsed_geob = GeneralEncapsulatedObject::parse(&*cont).unwrap();
|
||||
let parsed_geob = GeneralEncapsulatedObject::parse(&cont).unwrap();
|
||||
|
||||
assert_eq!(parsed_geob, expected);
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ impl EncodedTextFrame {
|
|||
pub fn as_bytes(&self) -> Vec<u8> {
|
||||
let mut bytes = vec![self.encoding as u8];
|
||||
|
||||
bytes.extend(encode_text(&*self.description, self.encoding, true).iter());
|
||||
bytes.extend(encode_text(&*self.content, self.encoding, false));
|
||||
bytes.extend(encode_text(&self.description, self.encoding, true).iter());
|
||||
bytes.extend(encode_text(&self.content, self.encoding, false));
|
||||
|
||||
bytes
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ impl LanguageFrame {
|
|||
}
|
||||
|
||||
bytes.extend(self.language.as_bytes().iter());
|
||||
bytes.extend(encode_text(&*self.description, self.encoding, true).iter());
|
||||
bytes.extend(encode_text(&*self.content, self.encoding, false));
|
||||
bytes.extend(encode_text(&self.description, self.encoding, true).iter());
|
||||
bytes.extend(encode_text(&self.content, self.encoding, false));
|
||||
|
||||
Ok(bytes)
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ mod tests {
|
|||
counter_bytes.len() - i
|
||||
};
|
||||
|
||||
assert_eq!((&popm_bytes[email.len() + 2..]).len(), counter_len);
|
||||
assert_eq!(popm_bytes[email.len() + 2..].len(), counter_len);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -145,7 +145,7 @@ impl SynchronizedText {
|
|||
|
||||
if let Some(raw_text) = read_to_terminator(&mut cursor, TextEncoding::UTF16)
|
||||
{
|
||||
return utf16_decode(&*raw_text, endianness)
|
||||
return utf16_decode(&raw_text, endianness)
|
||||
.map_err(|_| ID3v2Error::new(ID3v2ErrorKind::BadSyncText).into());
|
||||
}
|
||||
|
||||
|
@ -204,13 +204,13 @@ impl SynchronizedText {
|
|||
data.write_u8(information.content_type as u8)?;
|
||||
|
||||
if let Some(description) = &information.description {
|
||||
data.write_all(&*encode_text(description, information.encoding, true))?;
|
||||
data.write_all(&encode_text(description, information.encoding, true))?;
|
||||
} else {
|
||||
data.write_u8(0)?;
|
||||
}
|
||||
|
||||
for (time, ref text) in &self.content {
|
||||
data.write_all(&*encode_text(text, information.encoding, true))?;
|
||||
data.write_all(&encode_text(text, information.encoding, true))?;
|
||||
data.write_u32::<BigEndian>(*time)?;
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ mod tests {
|
|||
|
||||
let cont = crate::tag::utils::test_utils::read_path("tests/tags/assets/id3v2/test.sylt");
|
||||
|
||||
let parsed_sylt = SynchronizedText::parse(&*cont).unwrap();
|
||||
let parsed_sylt = SynchronizedText::parse(&cont).unwrap();
|
||||
|
||||
assert_eq!(parsed_sylt, expected);
|
||||
}
|
||||
|
|
|
@ -634,7 +634,7 @@ impl<'a, I: Iterator<Item = FrameRef<'a>> + 'a> Id3v2TagRef<'a, I> {
|
|||
|
||||
pub(crate) fn dump_to<W: Write>(&mut self, writer: &mut W) -> Result<()> {
|
||||
let temp = super::write::create_tag(self)?;
|
||||
writer.write_all(&*temp)?;
|
||||
writer.write_all(&temp)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ where
|
|||
|
||||
data.rewind()?;
|
||||
data.set_len(0)?;
|
||||
data.write_all(&*file_bytes)?;
|
||||
data.write_all(&file_bytes)?;
|
||||
}
|
||||
|
||||
if !tag.is_empty() {
|
||||
|
|
|
@ -66,7 +66,7 @@ pub(crate) fn write_id3v2<'a, I: Iterator<Item = FrameRef<'a>> + 'a>(
|
|||
|
||||
data.rewind()?;
|
||||
data.set_len(0)?;
|
||||
data.write_all(&*file_bytes)?;
|
||||
data.write_all(&file_bytes)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ where
|
|||
|
||||
pub(crate) fn dump_to<W: Write>(&mut self, writer: &mut W) -> Result<()> {
|
||||
let temp = Self::create_text_chunks(self)?;
|
||||
writer.write_all(&*temp)?;
|
||||
writer.write_all(&temp)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ where
|
|||
|
||||
data.rewind()?;
|
||||
data.set_len(0)?;
|
||||
data.write_all(&*file_bytes)?;
|
||||
data.write_all(&file_bytes)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ where
|
|||
let mut temp = Vec::new();
|
||||
write::create_riff_info(&mut self.items, &mut temp)?;
|
||||
|
||||
writer.write_all(&*temp)?;
|
||||
writer.write_all(&temp)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ where
|
|||
|
||||
data.rewind()?;
|
||||
data.set_len(0)?;
|
||||
data.write_all(&*file_bytes)?;
|
||||
data.write_all(&file_bytes)?;
|
||||
} else {
|
||||
data.seek(SeekFrom::End(0))?;
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ fn interpret_atom_content(flags: u32, content: Vec<u8>) -> Result<AtomData> {
|
|||
// https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW35
|
||||
Ok(match flags {
|
||||
UTF8 => AtomData::UTF8(String::from_utf8(content)?),
|
||||
UTF16 => AtomData::UTF16(utf16_decode(&*content, u16::from_be_bytes)?),
|
||||
UTF16 => AtomData::UTF16(utf16_decode(&content, u16::from_be_bytes)?),
|
||||
BE_SIGNED_INTEGER => AtomData::SignedInteger(parse_int(&content)?),
|
||||
BE_UNSIGNED_INTEGER => AtomData::UnsignedInteger(parse_uint(&content)?),
|
||||
code => AtomData::Unknown {
|
||||
|
|
|
@ -30,7 +30,7 @@ where
|
|||
|
||||
pub(crate) fn dump_to<W: Write>(&mut self, writer: &mut W) -> Result<()> {
|
||||
let temp = super::write::build_ilst(&mut self.atoms)?;
|
||||
writer.write_all(&*temp)?;
|
||||
writer.write_all(&temp)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -481,7 +481,7 @@ mod tests {
|
|||
expected_tag.insert(String::from("TRACKNUMBER"), String::from("1"), false);
|
||||
|
||||
let file_cont = crate::tag::utils::test_utils::read_path("tests/tags/assets/test.vorbis");
|
||||
let parsed_tag = read_tag(&*file_cont);
|
||||
let parsed_tag = read_tag(&file_cont);
|
||||
|
||||
assert_eq!(expected_tag, parsed_tag);
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ mod tests {
|
|||
#[test]
|
||||
fn vorbis_comments_re_read() {
|
||||
let file_cont = crate::tag::utils::test_utils::read_path("tests/tags/assets/test.vorbis");
|
||||
let mut parsed_tag = read_tag(&*file_cont);
|
||||
let mut parsed_tag = read_tag(&file_cont);
|
||||
|
||||
// Create a zero-size vendor for comparison
|
||||
parsed_tag.vendor = String::new();
|
||||
|
@ -497,7 +497,7 @@ mod tests {
|
|||
let mut writer = vec![0, 0, 0, 0];
|
||||
parsed_tag.dump_to(&mut writer).unwrap();
|
||||
|
||||
let temp_parsed_tag = read_tag(&*writer);
|
||||
let temp_parsed_tag = read_tag(&writer);
|
||||
|
||||
assert_eq!(parsed_tag, temp_parsed_tag);
|
||||
}
|
||||
|
|
|
@ -88,12 +88,12 @@ pub(crate) fn write_to(
|
|||
|
||||
for p in remaining_pages.iter_mut() {
|
||||
p.gen_crc()?;
|
||||
writer.write_all(&*p.as_bytes()?)?;
|
||||
writer.write_all(&p.as_bytes()?)?;
|
||||
}
|
||||
|
||||
build_remaining_header(writer, last_page, &*setup)?;
|
||||
build_remaining_header(writer, last_page, &setup)?;
|
||||
|
||||
writer.write_all(&*remaining)?;
|
||||
writer.write_all(&remaining)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ fn build_remaining_header(
|
|||
last_page.gen_crc()?;
|
||||
|
||||
let p_bytes = last_page.as_bytes()?;
|
||||
writer.write_all(&*p_bytes)?;
|
||||
writer.write_all(&p_bytes)?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -140,14 +140,14 @@ fn build_remaining_header(
|
|||
|
||||
// Replace segment table and checksum
|
||||
p_bytes.splice(26..27 + seg_count, segment_table);
|
||||
p_bytes.splice(22..26, ogg_pager::crc32(&*p_bytes).to_le_bytes());
|
||||
p_bytes.splice(22..26, ogg_pager::crc32(&p_bytes).to_le_bytes());
|
||||
|
||||
writer.write_all(&*p_bytes)?;
|
||||
writer.write_all(&p_bytes)?;
|
||||
|
||||
if let Some(mut page) = page {
|
||||
page.gen_crc()?;
|
||||
|
||||
writer.write_all(&*page.as_bytes()?)?;
|
||||
writer.write_all(&page.as_bytes()?)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -124,7 +124,7 @@ where
|
|||
|
||||
writer.write_u32::<LittleEndian>(bytes_len as u32)?;
|
||||
writer.write_all(PICTURE_KEY.as_bytes())?;
|
||||
writer.write_all(&*picture)?;
|
||||
writer.write_all(&picture)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ where
|
|||
let ser = first_page.serial;
|
||||
|
||||
let mut writer = Vec::new();
|
||||
writer.write_all(&*first_page.as_bytes()?)?;
|
||||
writer.write_all(&first_page.as_bytes()?)?;
|
||||
|
||||
let first_md_page = Page::read(data, false)?;
|
||||
|
||||
|
@ -207,7 +207,7 @@ where
|
|||
|
||||
data.rewind()?;
|
||||
data.set_len(first_page.end)?;
|
||||
data.write_all(&*writer)?;
|
||||
data.write_all(&writer)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -240,10 +240,10 @@ fn replace_packet(
|
|||
for p in pages.iter_mut() {
|
||||
p.gen_crc()?;
|
||||
|
||||
writer.write_all(&*p.as_bytes()?)?;
|
||||
writer.write_all(&p.as_bytes()?)?;
|
||||
}
|
||||
|
||||
writer.write_all(&*remaining)?;
|
||||
writer.write_all(&remaining)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -600,12 +600,12 @@ impl Picture {
|
|||
|
||||
match &self.description {
|
||||
Some(description) => {
|
||||
data.write_all(&*text_utils::encode_text(description, text_encoding, true))?
|
||||
data.write_all(&text_utils::encode_text(description, text_encoding, true))?
|
||||
},
|
||||
None => data.write_u8(0)?,
|
||||
}
|
||||
|
||||
data.write_all(&*self.data)?;
|
||||
data.write_all(&self.data)?;
|
||||
|
||||
if data.len() as u64 > max_size {
|
||||
return Err(LoftyError::new(ErrorKind::TooMuchData));
|
||||
|
@ -653,7 +653,7 @@ impl Picture {
|
|||
}
|
||||
} else {
|
||||
(text_utils::decode_text(&mut cursor, TextEncoding::UTF8, true)?)
|
||||
.map_or(MimeType::None, |mime_type| MimeType::from_str(&*mime_type))
|
||||
.map_or(MimeType::None, |mime_type| MimeType::from_str(&mime_type))
|
||||
};
|
||||
|
||||
let pic_type = PictureType::from_u8(cursor.read_u8()?);
|
||||
|
@ -737,7 +737,7 @@ impl Picture {
|
|||
if encoded {
|
||||
let data =
|
||||
base64::decode(bytes).map_err(|_| LoftyError::new(ErrorKind::NotAPicture))?;
|
||||
Self::from_flac_bytes_inner(&*data)
|
||||
Self::from_flac_bytes_inner(&data)
|
||||
} else {
|
||||
Self::from_flac_bytes_inner(bytes)
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ impl Tag {
|
|||
|
||||
/// Returns the stored [`TagItem`]s as a slice
|
||||
pub fn items(&self) -> &[TagItem] {
|
||||
&*self.items
|
||||
&self.items
|
||||
}
|
||||
|
||||
/// Returns a reference to a [`TagItem`] matching an [`ItemKey`]
|
||||
|
@ -411,7 +411,7 @@ impl Tag {
|
|||
|
||||
/// Returns the stored [`Picture`]s as a slice
|
||||
pub fn pictures(&self) -> &[Picture] {
|
||||
&*self.pictures
|
||||
&self.pictures
|
||||
}
|
||||
|
||||
/// Returns the first occurrence of the [`PictureType`]
|
||||
|
|
Loading…
Reference in a new issue