Default for vec / hashmap wrappers in metadata

- Derive `Default` trait for the vec / hashmap wrapper types in
  `librespot-metadata`
- The wrapped types (`Vec` / `Hashmap`) implement Default, so the
  wrapper types should as well
This commit is contained in:
Daniel M 2022-08-01 00:44:43 +02:00
parent e9f3b6d290
commit e7348db17c
18 changed files with 26 additions and 26 deletions

View file

@ -41,7 +41,7 @@ pub struct Album {
pub availability: Availabilities,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Albums(pub Vec<SpotifyId>);
impl Deref for Albums {
@ -58,7 +58,7 @@ pub struct Disc {
pub tracks: Tracks,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Discs(pub Vec<Disc>);
impl Deref for Discs {

View file

@ -20,7 +20,7 @@ pub struct Artist {
pub top_tracks: CountryTopTracks,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Artists(pub Vec<SpotifyId>);
impl Deref for Artists {
@ -37,7 +37,7 @@ pub struct ArtistWithRole {
pub role: ArtistRole,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct ArtistsWithRole(pub Vec<ArtistWithRole>);
impl Deref for ArtistsWithRole {
@ -53,7 +53,7 @@ pub struct TopTracks {
pub tracks: Tracks,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct CountryTopTracks(pub Vec<TopTracks>);
impl Deref for CountryTopTracks {

View file

@ -6,7 +6,7 @@ use librespot_protocol as protocol;
use protocol::metadata::AudioFile as AudioFileMessage;
pub use protocol::metadata::AudioFile_Format as AudioFileFormat;
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct AudioFiles(pub HashMap<AudioFileFormat, FileId>);
impl Deref for AudioFiles {

View file

@ -21,7 +21,7 @@ pub struct Availability {
pub start: Date,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Availabilities(pub Vec<Availability>);
impl Deref for Availabilities {

View file

@ -11,7 +11,7 @@ pub struct ContentRating {
pub tags: Vec<String>,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct ContentRatings(pub Vec<ContentRating>);
impl Deref for ContentRatings {

View file

@ -12,7 +12,7 @@ pub struct Copyright {
pub text: String,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Copyrights(pub Vec<Copyright>);
impl Deref for Copyrights {

View file

@ -52,7 +52,7 @@ pub struct Episode {
pub is_audiobook_chapter: bool,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Episodes(pub Vec<SpotifyId>);
impl Deref for Episodes {

View file

@ -11,7 +11,7 @@ pub struct ExternalId {
pub id: String, // this can be anything from a URL to a ISRC, EAN or UPC
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct ExternalIds(pub Vec<ExternalId>);
impl Deref for ExternalIds {

View file

@ -22,7 +22,7 @@ pub struct Image {
pub height: i32,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Images(pub Vec<Image>);
impl Deref for Images {
@ -38,7 +38,7 @@ pub struct PictureSize {
pub url: String,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct PictureSizes(pub Vec<PictureSize>);
impl Deref for PictureSizes {

View file

@ -34,7 +34,7 @@ pub struct PlaylistAttributes {
pub picture_sizes: PictureSizes,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct PlaylistAttributeKinds(pub Vec<PlaylistAttributeKind>);
impl Deref for PlaylistAttributeKinds {
@ -46,7 +46,7 @@ impl Deref for PlaylistAttributeKinds {
from_repeated_enum!(PlaylistAttributeKind, PlaylistAttributeKinds);
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct PlaylistFormatAttribute(pub HashMap<String, String>);
impl Deref for PlaylistFormatAttribute {
@ -66,7 +66,7 @@ pub struct PlaylistItemAttributes {
pub item_id: Vec<u8>,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct PlaylistItemAttributeKinds(pub Vec<PlaylistItemAttributeKind>);
impl Deref for PlaylistItemAttributeKinds {

View file

@ -24,7 +24,7 @@ pub struct PlaylistItem {
pub attributes: PlaylistItemAttributes,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct PlaylistItems(pub Vec<PlaylistItem>);
impl Deref for PlaylistItems {
@ -53,7 +53,7 @@ pub struct PlaylistMetaItem {
pub capabilities: Capabilities,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct PlaylistMetaItems(pub Vec<PlaylistMetaItem>);
impl Deref for PlaylistMetaItems {

View file

@ -26,7 +26,7 @@ use librespot_core::{
use librespot_protocol as protocol;
use protocol::playlist4_external::GeoblockBlockingType as Geoblock;
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Geoblocks(Vec<Geoblock>);
impl Deref for Geoblocks {
@ -55,7 +55,7 @@ pub struct Playlist {
pub geoblocks: Geoblocks,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Playlists(pub Vec<SpotifyId>);
impl Deref for Playlists {

View file

@ -29,7 +29,7 @@ pub struct PlaylistOperation {
pub update_list_attributes: PlaylistUpdateAttributes,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct PlaylistOperations(pub Vec<PlaylistOperation>);
impl Deref for PlaylistOperations {

View file

@ -16,7 +16,7 @@ pub struct Capabilities {
pub can_cancel_membership: bool,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct PermissionLevels(pub Vec<PermissionLevel>);
impl Deref for PermissionLevels {

View file

@ -17,7 +17,7 @@ pub struct Restriction {
pub countries_forbidden: Option<Vec<String>>,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Restrictions(pub Vec<Restriction>);
impl Deref for Restrictions {

View file

@ -18,7 +18,7 @@ pub struct SalePeriod {
pub end: Date,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct SalePeriods(pub Vec<SalePeriod>);
impl Deref for SalePeriods {

View file

@ -53,7 +53,7 @@ pub struct Track {
pub artists_with_role: ArtistsWithRole,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Tracks(pub Vec<SpotifyId>);
impl Deref for Tracks {

View file

@ -7,7 +7,7 @@ use librespot_core::FileId;
use librespot_protocol as protocol;
use protocol::metadata::VideoFile as VideoFileMessage;
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct VideoFiles(pub Vec<FileId>);
impl Deref for VideoFiles {