From e7348db17c8dead6dad16efb45fa38b6468af91f Mon Sep 17 00:00:00 2001 From: Daniel M Date: Mon, 1 Aug 2022 00:44:43 +0200 Subject: [PATCH] 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 --- metadata/src/album.rs | 4 ++-- metadata/src/artist.rs | 6 +++--- metadata/src/audio/file.rs | 2 +- metadata/src/availability.rs | 2 +- metadata/src/content_rating.rs | 2 +- metadata/src/copyright.rs | 2 +- metadata/src/episode.rs | 2 +- metadata/src/external_id.rs | 2 +- metadata/src/image.rs | 4 ++-- metadata/src/playlist/attribute.rs | 6 +++--- metadata/src/playlist/item.rs | 4 ++-- metadata/src/playlist/list.rs | 4 ++-- metadata/src/playlist/operation.rs | 2 +- metadata/src/playlist/permission.rs | 2 +- metadata/src/restriction.rs | 2 +- metadata/src/sale_period.rs | 2 +- metadata/src/track.rs | 2 +- metadata/src/video.rs | 2 +- 18 files changed, 26 insertions(+), 26 deletions(-) diff --git a/metadata/src/album.rs b/metadata/src/album.rs index 8a372245..42b5d1e3 100644 --- a/metadata/src/album.rs +++ b/metadata/src/album.rs @@ -41,7 +41,7 @@ pub struct Album { pub availability: Availabilities, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Albums(pub Vec); 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); impl Deref for Discs { diff --git a/metadata/src/artist.rs b/metadata/src/artist.rs index ac07d90e..c6e2925e 100644 --- a/metadata/src/artist.rs +++ b/metadata/src/artist.rs @@ -20,7 +20,7 @@ pub struct Artist { pub top_tracks: CountryTopTracks, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Artists(pub Vec); 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); 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); impl Deref for CountryTopTracks { diff --git a/metadata/src/audio/file.rs b/metadata/src/audio/file.rs index 237b8e31..49f910d0 100644 --- a/metadata/src/audio/file.rs +++ b/metadata/src/audio/file.rs @@ -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); impl Deref for AudioFiles { diff --git a/metadata/src/availability.rs b/metadata/src/availability.rs index 09016a5b..aca7667f 100644 --- a/metadata/src/availability.rs +++ b/metadata/src/availability.rs @@ -21,7 +21,7 @@ pub struct Availability { pub start: Date, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Availabilities(pub Vec); impl Deref for Availabilities { diff --git a/metadata/src/content_rating.rs b/metadata/src/content_rating.rs index 343f0e26..ee2e4638 100644 --- a/metadata/src/content_rating.rs +++ b/metadata/src/content_rating.rs @@ -11,7 +11,7 @@ pub struct ContentRating { pub tags: Vec, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct ContentRatings(pub Vec); impl Deref for ContentRatings { diff --git a/metadata/src/copyright.rs b/metadata/src/copyright.rs index b7f0e838..f4fb0202 100644 --- a/metadata/src/copyright.rs +++ b/metadata/src/copyright.rs @@ -12,7 +12,7 @@ pub struct Copyright { pub text: String, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Copyrights(pub Vec); impl Deref for Copyrights { diff --git a/metadata/src/episode.rs b/metadata/src/episode.rs index c5b65f80..d91e721e 100644 --- a/metadata/src/episode.rs +++ b/metadata/src/episode.rs @@ -52,7 +52,7 @@ pub struct Episode { pub is_audiobook_chapter: bool, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Episodes(pub Vec); impl Deref for Episodes { diff --git a/metadata/src/external_id.rs b/metadata/src/external_id.rs index b310200a..1573570b 100644 --- a/metadata/src/external_id.rs +++ b/metadata/src/external_id.rs @@ -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); impl Deref for ExternalIds { diff --git a/metadata/src/image.rs b/metadata/src/image.rs index 495158d6..7540ff54 100644 --- a/metadata/src/image.rs +++ b/metadata/src/image.rs @@ -22,7 +22,7 @@ pub struct Image { pub height: i32, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Images(pub Vec); 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); impl Deref for PictureSizes { diff --git a/metadata/src/playlist/attribute.rs b/metadata/src/playlist/attribute.rs index d271bc54..24695196 100644 --- a/metadata/src/playlist/attribute.rs +++ b/metadata/src/playlist/attribute.rs @@ -34,7 +34,7 @@ pub struct PlaylistAttributes { pub picture_sizes: PictureSizes, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct PlaylistAttributeKinds(pub Vec); 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); impl Deref for PlaylistFormatAttribute { @@ -66,7 +66,7 @@ pub struct PlaylistItemAttributes { pub item_id: Vec, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct PlaylistItemAttributeKinds(pub Vec); impl Deref for PlaylistItemAttributeKinds { diff --git a/metadata/src/playlist/item.rs b/metadata/src/playlist/item.rs index 20f94a0b..0c413892 100644 --- a/metadata/src/playlist/item.rs +++ b/metadata/src/playlist/item.rs @@ -24,7 +24,7 @@ pub struct PlaylistItem { pub attributes: PlaylistItemAttributes, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct PlaylistItems(pub Vec); 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); impl Deref for PlaylistMetaItems { diff --git a/metadata/src/playlist/list.rs b/metadata/src/playlist/list.rs index a8ef677b..db6c14c0 100644 --- a/metadata/src/playlist/list.rs +++ b/metadata/src/playlist/list.rs @@ -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); 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); impl Deref for Playlists { diff --git a/metadata/src/playlist/operation.rs b/metadata/src/playlist/operation.rs index fe33d0dc..5897ce5f 100644 --- a/metadata/src/playlist/operation.rs +++ b/metadata/src/playlist/operation.rs @@ -29,7 +29,7 @@ pub struct PlaylistOperation { pub update_list_attributes: PlaylistUpdateAttributes, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct PlaylistOperations(pub Vec); impl Deref for PlaylistOperations { diff --git a/metadata/src/playlist/permission.rs b/metadata/src/playlist/permission.rs index 2923a636..8d8c6592 100644 --- a/metadata/src/playlist/permission.rs +++ b/metadata/src/playlist/permission.rs @@ -16,7 +16,7 @@ pub struct Capabilities { pub can_cancel_membership: bool, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct PermissionLevels(pub Vec); impl Deref for PermissionLevels { diff --git a/metadata/src/restriction.rs b/metadata/src/restriction.rs index 279da342..be3ed2b7 100644 --- a/metadata/src/restriction.rs +++ b/metadata/src/restriction.rs @@ -17,7 +17,7 @@ pub struct Restriction { pub countries_forbidden: Option>, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Restrictions(pub Vec); impl Deref for Restrictions { diff --git a/metadata/src/sale_period.rs b/metadata/src/sale_period.rs index b02d2368..5b5752bc 100644 --- a/metadata/src/sale_period.rs +++ b/metadata/src/sale_period.rs @@ -18,7 +18,7 @@ pub struct SalePeriod { pub end: Date, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct SalePeriods(pub Vec); impl Deref for SalePeriods { diff --git a/metadata/src/track.rs b/metadata/src/track.rs index 4ab9b2b4..cefe7519 100644 --- a/metadata/src/track.rs +++ b/metadata/src/track.rs @@ -53,7 +53,7 @@ pub struct Track { pub artists_with_role: ArtistsWithRole, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct Tracks(pub Vec); impl Deref for Tracks { diff --git a/metadata/src/video.rs b/metadata/src/video.rs index 5e883339..eab9e057 100644 --- a/metadata/src/video.rs +++ b/metadata/src/video.rs @@ -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); impl Deref for VideoFiles {