Add TagExt::clear

This commit is contained in:
Serial 2022-03-18 15:22:40 -04:00
parent 4b51453ce7
commit 12b919871d
No known key found for this signature in database
GPG key ID: DA95198DC17C4568
10 changed files with 40 additions and 1 deletions

View file

@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **MP4**: `mp4::AudioObjectType`
- This new type is used in `mp4::Mp4Properties`, accessible with `Mp4Properties::audio_object_type`.
This provides additional information for the type of audio being dealt with.
- `TagExt::clear`
- This allows tags to be cleared of any items or pictures, while retaining any flags (if applicable)
### Changed
- **MP4**: Sample rates are now retrieved from the [audio specific config](https://wiki.multimedia.cx/index.php?title=MPEG-4_Audio#Audio_Specific_Config) (if possible).

View file

@ -171,6 +171,10 @@ impl TagExt for ApeTag {
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
TagType::Ape.remove_from(file)
}
fn clear(&mut self) {
self.items.clear();
}
}
impl From<ApeTag> for Tag {

View file

@ -148,6 +148,10 @@ impl TagExt for Id3v1Tag {
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
TagType::Id3v1.remove_from(file)
}
fn clear(&mut self) {
*self = Self::default();
}
}
impl From<Id3v1Tag> for Tag {

View file

@ -318,6 +318,10 @@ impl TagExt for Id3v2Tag {
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
TagType::Id3v2.remove_from(file)
}
fn clear(&mut self) {
self.frames.clear();
}
}
impl From<Id3v2Tag> for Tag {

View file

@ -169,6 +169,10 @@ impl TagExt for AiffTextChunks {
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
TagType::AiffText.remove_from(file)
}
fn clear(&mut self) {
*self = Self::default();
}
}
impl From<AiffTextChunks> for Tag {

View file

@ -127,6 +127,10 @@ impl TagExt for RiffInfoList {
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
TagType::RiffInfo.remove_from(file)
}
fn clear(&mut self) {
self.items.clear();
}
}
impl From<RiffInfoList> for Tag {

View file

@ -250,6 +250,10 @@ impl TagExt for Ilst {
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
TagType::Mp4Ilst.remove_from(file)
}
fn clear(&mut self) {
self.atoms.clear();
}
}
impl From<Ilst> for Tag {

View file

@ -194,6 +194,11 @@ impl TagExt for VorbisComments {
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
TagType::VorbisComments.remove_from(file)
}
fn clear(&mut self) {
self.items.clear();
self.pictures.clear();
}
}
impl From<VorbisComments> for Tag {

View file

@ -395,6 +395,11 @@ impl TagExt for Tag {
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
self.tag_type.remove_from(file)
}
fn clear(&mut self) {
self.items.clear();
self.pictures.clear();
}
}
/// The tag's format

View file

@ -129,5 +129,8 @@ pub trait TagExt: Accessor + Into<Tag> + Sized {
/// * It is unable to write to the file
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err>;
// TODO: clear method
/// Clear the tag, removing all items
///
/// NOTE: This will **not** remove any format-specific extras, such as flags
fn clear(&mut self);
}