Remove old trait

This commit is contained in:
Serial 2021-04-20 12:21:09 -04:00
parent 8c79ea46cb
commit 0dd57cc4da
5 changed files with 20 additions and 67 deletions

View file

@ -1,7 +1,7 @@
#![cfg(feature = "ape")]
use crate::{
impl_tag, traits::ReadPath, Album, AnyTag, AudioTag, AudioTagEdit, AudioTagWrite, Picture,
impl_tag, Album, AnyTag, AudioTag, AudioTagEdit, AudioTagWrite, Picture,
Result, TagType, ToAny, ToAnyTag,
};
@ -9,16 +9,6 @@ pub use ape::Tag as ApeInnerTag;
use filepath::FilePath;
use std::{fs::File, path::Path};
impl ReadPath for ApeInnerTag {
fn from_path<P>(path: P) -> Result<Self>
where
P: AsRef<std::path::Path>,
Self: Sized,
{
Ok(ape::read(path)?)
}
}
impl_tag!(ApeTag, ApeInnerTag, TagType::Ape);
impl ApeTag {
@ -27,7 +17,7 @@ impl ApeTag {
where
P: AsRef<Path>,
{
Ok(Self(ApeInnerTag::from_path(path)?))
Ok(Self(ape::read(path)?))
}
}

View file

@ -1,7 +1,7 @@
#![cfg(feature = "mp3")]
use crate::{
impl_tag, traits::ReadPath, Album, AnyTag, AudioTag, AudioTagEdit, AudioTagWrite, Error,
impl_tag, Album, AnyTag, AudioTag, AudioTagEdit, AudioTagWrite, Error,
MimeType, Picture, Result, TagType, ToAny, ToAnyTag,
};
@ -10,16 +10,6 @@ use std::convert::TryInto;
use std::fs::File;
use std::path::Path;
impl ReadPath for Id3v2InnerTag {
fn from_path<P>(path: P) -> Result<Self>
where
P: AsRef<std::path::Path>,
Self: Sized,
{
Ok(Self::read_from_path(path)?)
}
}
impl_tag!(Id3v2Tag, Id3v2InnerTag, TagType::Id3v2);
impl Id3v2Tag {
@ -28,7 +18,7 @@ impl Id3v2Tag {
where
P: AsRef<Path>,
{
Ok(Self(Id3v2InnerTag::from_path(path)?))
Ok(Self(Id3v2InnerTag::read_from_path(path)?))
}
}

View file

@ -1,7 +1,7 @@
#![cfg(feature = "mp4")]
use crate::{
impl_tag, traits::ReadPath, Album, AnyTag, AudioTag, AudioTagEdit, AudioTagWrite, Error,
impl_tag, Album, AnyTag, AudioTag, AudioTagEdit, AudioTagWrite, Error,
MimeType, Picture, Result, TagType, ToAny, ToAnyTag,
};
@ -9,16 +9,6 @@ pub use mp4ameta::{FourCC, Tag as Mp4InnerTag};
use std::fs::File;
use std::path::Path;
impl ReadPath for Mp4InnerTag {
fn from_path<P>(path: P) -> Result<Self>
where
P: AsRef<std::path::Path>,
Self: Sized,
{
Ok(Self::read_from_path(path)?)
}
}
impl_tag!(Mp4Tag, Mp4InnerTag, TagType::Mp4);
impl Mp4Tag {
@ -27,7 +17,7 @@ impl Mp4Tag {
where
P: AsRef<Path>,
{
Ok(Self(Mp4InnerTag::from_path(path)?))
Ok(Self(Mp4InnerTag::read_from_path(path)?))
}
}
@ -164,7 +154,6 @@ impl AudioTagEdit for Mp4Tag {
}
fn remove_album_artists(&mut self) {
self.0.remove_data(&FourCC(*b"aART"));
self.0.remove_album_artists();
}
fn album_cover(&self) -> Option<Picture> {

View file

@ -1,5 +1,5 @@
use crate::{
components::logic, impl_tag, traits::ReadPath, Album, AnyTag, AudioTag, AudioTagEdit,
components::logic, impl_tag, Album, AnyTag, AudioTag, AudioTagEdit,
AudioTagWrite, Picture, Result, TagType, ToAny, ToAnyTag,
};
@ -12,18 +12,6 @@ struct WavInnerTag {
data: Option<HashMap<String, String>>,
}
impl ReadPath for WavInnerTag {
fn from_path<P>(path: P) -> Result<Self>
where
P: AsRef<std::path::Path>,
Self: Sized,
{
let data = logic::read::wav(File::open(path)?)?;
Ok(Self { data })
}
}
impl Default for WavInnerTag {
fn default() -> Self {
let data: Option<HashMap<String, String>> = Some(HashMap::new());
@ -32,6 +20,18 @@ impl Default for WavInnerTag {
}
}
impl WavTag {
#[allow(clippy::missing_errors_doc)]
pub fn read_from_path<P>(path: P) -> Result<Self>
where
P: AsRef<Path>,
{
Ok(Self(WavInnerTag {
data: logic::read::wav(File::open(path)?)?
}))
}
}
impl_tag!(WavTag, WavInnerTag, TagType::Wav);
impl<'a> From<AnyTag<'a>> for WavTag {
@ -90,16 +90,6 @@ impl<'a> From<&'a WavTag> for AnyTag<'a> {
}
}
impl WavTag {
#[allow(clippy::missing_errors_doc)]
pub fn read_from_path<P>(path: P) -> Result<Self>
where
P: AsRef<Path>,
{
Ok(Self(WavInnerTag::from_path(path)?))
}
}
impl WavTag {
fn get_value(&self, key: &str) -> Option<&str> {
self.0

View file

@ -85,6 +85,7 @@ pub trait AudioTagEdit {
fn total_discs(&self) -> Option<u32>;
fn set_total_discs(&mut self, total_discs: u32);
fn remove_total_discs(&mut self);
}
pub trait AudioTagWrite {
@ -128,10 +129,3 @@ pub trait ToAny {
fn to_any(&self) -> &dyn std::any::Any;
fn to_any_mut(&mut self) -> &mut dyn std::any::Any;
}
pub trait ReadPath {
fn from_path<P>(path: P) -> Result<Self>
where
P: AsRef<std::path::Path>,
Self: Sized;
}