Add mutable getter methods for all file tags

This commit is contained in:
Serial 2021-09-07 01:46:42 -04:00
parent 4394d9bf8f
commit adb8db9dde
8 changed files with 85 additions and 0 deletions

View file

@ -58,15 +58,33 @@ impl ApeFile {
self.id3v2.as_ref()
}
#[cfg(feature = "id3v2")]
/// Returns a mutable reference to the ID3v2 tag if it exists
pub fn id3v2_tag_mut(&mut self) -> Option<&mut Tag> {
self.id3v2.as_mut()
}
#[cfg(feature = "id3v1")]
/// Returns a reference to the ID3v1 tag if it exists
pub fn id3v1_tag(&self) -> Option<&Tag> {
self.id3v1.as_ref()
}
#[cfg(feature = "id3v1")]
/// Returns a mutable reference to the ID3v1 tag if it exists
pub fn id3v1_tag_mut(&mut self) -> Option<&mut Tag> {
self.id3v1.as_mut()
}
#[cfg(feature = "ape")]
/// Returns a reference to the APEv1/2 tag if it exists
pub fn ape_tag(&self) -> Option<&Tag> {
self.ape.as_ref()
}
#[cfg(feature = "ape")]
/// Returns a mutable reference to the APEv1/2 tag if it exists
pub fn ape_tag_mut(&mut self) -> Option<&mut Tag> {
self.ape.as_mut()
}
}

View file

@ -53,9 +53,21 @@ impl AiffFile {
self.id3v2.as_ref()
}
#[cfg(feature = "id3v2")]
/// Returns a mutable reference to the ID3v2 tag if it exists
pub fn id3v2_tag_mut(&mut self) -> Option<&mut Tag> {
self.id3v2.as_mut()
}
#[cfg(feature = "aiff_text_chunks")]
/// Returns a reference to the text chunks tag if it exists
pub fn text_chunks(&self) -> Option<&Tag> {
self.text_chunks.as_ref()
}
#[cfg(feature = "aiff_text_chunks")]
/// Returns a mutable reference to the text chunks tag if it exists
pub fn text_chunks_mut(&mut self) -> Option<&mut Tag> {
self.text_chunks.as_mut()
}
}

View file

@ -53,9 +53,21 @@ impl WavFile {
self.id3v2.as_ref()
}
#[cfg(feature = "id3v2")]
/// Returns a mutable reference to the ID3v2 tag if it exists
pub fn id3v2_tag_mut(&mut self) -> Option<&mut Tag> {
self.id3v2.as_mut()
}
#[cfg(feature = "riff_info_list")]
/// Returns a reference to the RIFF INFO tag if it exists
pub fn riff_info(&self) -> Option<&Tag> {
self.riff_info.as_ref()
}
#[cfg(feature = "riff_info_list")]
/// Returns a mutable reference to the RIFF INFO tag if it exists
pub fn riff_info_mut(&mut self) -> Option<&mut Tag> {
self.riff_info.as_mut()
}
}

View file

@ -50,9 +50,16 @@ impl Mp4File {
pub fn ftyp(&self) -> &str {
self.ftyp.as_ref()
}
#[cfg(feature = "mp4_atoms")]
/// Returns a reference to the "ilst" tag if it exists
pub fn ilst(&self) -> Option<&Tag> {
self.ilst.as_ref()
}
#[cfg(feature = "mp4_atoms")]
/// Returns a mutable reference to the "ilst" tag if it exists
pub fn ilst_mut(&mut self) -> Option<&mut Tag> {
self.ilst.as_mut()
}
}

View file

@ -55,15 +55,33 @@ impl MpegFile {
self.id3v2.as_ref()
}
#[cfg(feature = "id3v2")]
/// Returns a mutable reference to the ID3v2 tag if it exists
pub fn id3v2_tag_mut(&mut self) -> Option<&mut Tag> {
self.id3v2.as_mut()
}
#[cfg(feature = "id3v1")]
/// Returns a reference to the ID3v1 tag if it exists
pub fn id3v1_tag(&self) -> Option<&Tag> {
self.id3v1.as_ref()
}
#[cfg(feature = "id3v1")]
/// Returns a mutable reference to the ID3v1 tag if it exists
pub fn id3v1_tag_mut(&mut self) -> Option<&mut Tag> {
self.id3v1.as_mut()
}
#[cfg(feature = "ape")]
/// Returns a reference to the APEv1/2 tag if it exists
pub fn ape_tag(&self) -> Option<&Tag> {
self.ape.as_ref()
}
#[cfg(feature = "ape")]
/// Returns a mutable reference to the APEv1/2 tag if it exists
pub fn ape_tag_mut(&mut self) -> Option<&mut Tag> {
self.ape.as_mut()
}
}

View file

@ -54,4 +54,10 @@ impl FlacFile {
pub fn vorbis_comments(&self) -> Option<&Tag> {
self.vorbis_comments.as_ref()
}
#[cfg(feature = "vorbis_comments")]
/// Returns a mutable reference to the Vorbis comments tag if it exists
pub fn vorbis_comments_mut(&mut self) -> Option<&mut Tag> {
self.vorbis_comments.as_mut()
}
}

View file

@ -61,4 +61,10 @@ impl OpusFile {
pub fn vorbis_comments(&self) -> &Tag {
&self.vorbis_comments
}
#[cfg(feature = "vorbis_comments")]
/// Returns a mutable reference to the Vorbis comments tag
pub fn vorbis_comments_mut(&mut self) -> &mut Tag {
&mut self.vorbis_comments
}
}

View file

@ -62,4 +62,10 @@ impl VorbisFile {
pub fn vorbis_comments(&self) -> &Tag {
&self.vorbis_comments
}
#[cfg(feature = "vorbis_comments")]
/// Returns a mutable reference to the Vorbis comments tag
pub fn vorbis_comments_mut(&mut self) -> &mut Tag {
&mut self.vorbis_comments
}
}