From f9b590472debff1aababa716cd61892403f0c091 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 21 Nov 2025 14:18:44 +0900 Subject: [PATCH] commands: implement common traits for responses --- src/commands/music_database/albumart.rs | 3 +++ src/commands/music_database/count.rs | 3 +++ src/commands/music_database/find.rs | 3 +++ src/commands/music_database/getfingerprint.rs | 3 +++ src/commands/music_database/readpicture.rs | 3 +++ src/commands/music_database/rescan.rs | 3 +++ src/commands/music_database/search.rs | 3 +++ src/commands/music_database/searchcount.rs | 3 +++ src/commands/music_database/update.rs | 3 +++ src/commands/queue/addid.rs | 3 +++ src/commands/reflection/config.rs | 3 +++ src/commands/stickers/sticker_find.rs | 3 +++ src/commands/stored_playlists/playlistlength.rs | 3 +++ 13 files changed, 39 insertions(+) diff --git a/src/commands/music_database/albumart.rs b/src/commands/music_database/albumart.rs index d8313d3..ad977ae 100644 --- a/src/commands/music_database/albumart.rs +++ b/src/commands/music_database/albumart.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use crate::{ commands::{ Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, @@ -10,6 +12,7 @@ use crate::{ pub struct AlbumArt; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct AlbumArtResponse { pub size: usize, pub binary: Vec, diff --git a/src/commands/music_database/count.rs b/src/commands/music_database/count.rs index 00bb131..4de8833 100644 --- a/src/commands/music_database/count.rs +++ b/src/commands/music_database/count.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use crate::{ commands::{ Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, @@ -10,6 +12,7 @@ use crate::{ pub struct Count; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct CountResponse { pub songs: usize, pub playtime: u64, diff --git a/src/commands/music_database/find.rs b/src/commands/music_database/find.rs index 4ce5cd6..48c6852 100644 --- a/src/commands/music_database/find.rs +++ b/src/commands/music_database/find.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ commands::{ Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, @@ -8,6 +10,7 @@ use crate::{ pub struct Find; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct FindResponse {} impl Command for Find { diff --git a/src/commands/music_database/getfingerprint.rs b/src/commands/music_database/getfingerprint.rs index 4dfaf60..7e33fbf 100644 --- a/src/commands/music_database/getfingerprint.rs +++ b/src/commands/music_database/getfingerprint.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use crate::commands::{ Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError, get_and_parse_property, @@ -7,6 +9,7 @@ use crate::commands::{ pub struct GetFingerprint; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct GetFingerprintResponse { pub chromaprint: String, } diff --git a/src/commands/music_database/readpicture.rs b/src/commands/music_database/readpicture.rs index 86babc7..ca25957 100644 --- a/src/commands/music_database/readpicture.rs +++ b/src/commands/music_database/readpicture.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use crate::{ commands::{ Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, @@ -10,6 +12,7 @@ use crate::{ pub struct ReadPicture; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ReadPictureResponse { pub size: usize, pub binary: Vec, diff --git a/src/commands/music_database/rescan.rs b/src/commands/music_database/rescan.rs index 94022bf..5c186a2 100644 --- a/src/commands/music_database/rescan.rs +++ b/src/commands/music_database/rescan.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use crate::commands::{ Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError, get_and_parse_property, @@ -7,6 +9,7 @@ use crate::commands::{ pub struct Rescan; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct RescanResponse { pub updating_db: usize, } diff --git a/src/commands/music_database/search.rs b/src/commands/music_database/search.rs index fe7bcdc..51d121a 100644 --- a/src/commands/music_database/search.rs +++ b/src/commands/music_database/search.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ commands::{ Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, @@ -8,6 +10,7 @@ use crate::{ pub struct Search; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct SearchResponse {} impl Command for Search { diff --git a/src/commands/music_database/searchcount.rs b/src/commands/music_database/searchcount.rs index be481f9..bc4cf08 100644 --- a/src/commands/music_database/searchcount.rs +++ b/src/commands/music_database/searchcount.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use crate::{ commands::{ Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, @@ -10,6 +12,7 @@ use crate::{ pub struct SearchCount; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct SearchCountResponse { pub songs: usize, pub playtime: u64, diff --git a/src/commands/music_database/update.rs b/src/commands/music_database/update.rs index dd1406e..d07d797 100644 --- a/src/commands/music_database/update.rs +++ b/src/commands/music_database/update.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use crate::commands::{ Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError, get_and_parse_property, @@ -7,6 +9,7 @@ use crate::commands::{ pub struct Update; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct UpdateResponse { updating_db: usize, } diff --git a/src/commands/queue/addid.rs b/src/commands/queue/addid.rs index 2701d17..fe708d6 100644 --- a/src/commands/queue/addid.rs +++ b/src/commands/queue/addid.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::{ commands::{ Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, @@ -8,6 +10,7 @@ use crate::{ pub struct AddId; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct AddIdResponse { pub id: SongId, } diff --git a/src/commands/reflection/config.rs b/src/commands/reflection/config.rs index 45fd61a..d012ea2 100644 --- a/src/commands/reflection/config.rs +++ b/src/commands/reflection/config.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use crate::commands::{ Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError, get_and_parse_property, get_property, @@ -7,6 +9,7 @@ use crate::commands::{ pub struct Config; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ConfigResponse { pub music_directory: String, pub playlist_directory: String, diff --git a/src/commands/stickers/sticker_find.rs b/src/commands/stickers/sticker_find.rs index 5f01935..87c64db 100644 --- a/src/commands/stickers/sticker_find.rs +++ b/src/commands/stickers/sticker_find.rs @@ -1,3 +1,5 @@ +use serde::{Deserialize, Serialize}; + use crate::commands::{ Command, GenericResponseValue, Request, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError, @@ -5,6 +7,7 @@ use crate::commands::{ pub struct StickerFind; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct StickerFindResponseEntry { pub uri: String, pub name: String, diff --git a/src/commands/stored_playlists/playlistlength.rs b/src/commands/stored_playlists/playlistlength.rs index a66dcdc..9ff541d 100644 --- a/src/commands/stored_playlists/playlistlength.rs +++ b/src/commands/stored_playlists/playlistlength.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use crate::commands::{ Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError, get_and_parse_property, @@ -7,6 +9,7 @@ use crate::commands::{ pub struct PlaylistLength; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct PlaylistLengthResponse { pub songs: u64, pub playtime: u64,