TianyiShi2001 / audiotags

Unified IO for different types of audio metadata
https://tianyishi2001.github.io/audiotags
MIT License
43 stars 30 forks source link

implement `AnyTag` to allow conversion between different tag types #2

Closed TianyiShi2001 closed 4 years ago

TianyiShi2001 commented 4 years ago

implementing an AnyTag struct, e,g.

pub struct AnyTag {
    pub title: Option<String>,
    pub artists: Option<Vec<String>>,
    pub year: Option<i32>,
    pub album_title: Option<String>,
    pub album_artists: Option<Vec<String>>,
    pub album_cover: Option<Picture>,
    pub track_number: Option<u16>,
    pub total_tracks: Option<u16>,
    pub disc_number: Option<u16>,
    pub total_discs: Option<u16>,
    ...
}

and corresponding From traits for different specific tag formats will allow conversions between them.

The challenge is: can this be implemented without copying (cloning)? i.e. can the above be implemented as:

pub struct AnyTag1<'a> {
    pub title: Option<&'a str>,
    pub artists: Option<Vec<&'a str>>,
    pub year: Option<i32>,
    pub album_title: Option<&'a str>,
    pub album_artists: Option<Vec<&'a str>>,
    pub album_cover: Option<&'a Picture>,
    pub track_number: Option<u16>,
    pub total_tracks: Option<u16>,
    pub disc_number: Option<u16>,
    pub total_discs: Option<u16>,
}
TianyiShi2001 commented 4 years ago

Currently I'm using beef::lean::Cow to do this. Is this necessary?