diff --git a/src/rest/get_album.rs b/src/rest/get_album.rs index 69a1e75..3385c49 100644 --- a/src/rest/get_album.rs +++ b/src/rest/get_album.rs @@ -31,7 +31,7 @@ pub async fn get_album( duration: 100, songs: vec![ Child { - id: 111, + id: "tr-111".to_string(), title: "Example - 1".to_string(), album: Some("Example".to_string()), duration: Some(20), @@ -44,7 +44,7 @@ pub async fn get_album( ..Default::default() }, Child { - id: 112, + id: "tr-112".to_string(), title: "Example - 2".to_string(), album: Some("Example".to_string()), duration: Some(20), @@ -57,7 +57,7 @@ pub async fn get_album( ..Default::default() }, Child { - id: 113, + id: "tr-113".to_string(), title: "Example - 3".to_string(), album: Some("Example".to_string()), duration: Some(20), @@ -70,7 +70,7 @@ pub async fn get_album( ..Default::default() }, Child { - id: 114, + id: "tr-114".to_string(), title: "Example - 4".to_string(), album: Some("Example".to_string()), duration: Some(20), @@ -83,7 +83,7 @@ pub async fn get_album( ..Default::default() }, Child { - id: 115, + id: "tr-115".to_string(), title: "Example - 5".to_string(), album: Some("Example".to_string()), duration: Some(20), diff --git a/src/rest/get_album_list.rs b/src/rest/get_album_list.rs index c79ed9d..2ab6568 100644 --- a/src/rest/get_album_list.rs +++ b/src/rest/get_album_list.rs @@ -29,7 +29,7 @@ pub async fn get_album_list( let album_list = vec![ Child { - id: 11, + id: "al-11".to_string(), parent: Some(1), title: "Example".to_string(), artist: Some("Example".to_string()), @@ -37,7 +37,7 @@ pub async fn get_album_list( ..Default::default() }, Child { - id: 12, + id: "al-12".to_string(), parent: Some(1), title: "Example 2".to_string(), artist: Some("Example 2".to_string()), diff --git a/src/subsonic.rs b/src/subsonic.rs index 72a83b0..2458832 100644 --- a/src/subsonic.rs +++ b/src/subsonic.rs @@ -3,7 +3,7 @@ use std::fmt::Display; use poem::{http::StatusCode, IntoResponse, Response}; -use serde::{ser::SerializeStruct, Serialize}; +use serde::{ser::SerializeStruct, Serialize, Serializer}; use time::OffsetDateTime; use crate::authentication::VersionTriple; @@ -99,7 +99,7 @@ pub enum SubResponseType { #[derive(Debug, Clone, Serialize, Default)] pub struct AlbumId3 { - #[serde(rename = "@id")] + #[serde(rename = "@id", serialize_with = "album_id")] pub id: i32, #[serde(rename = "@parent")] pub name: String, @@ -127,11 +127,18 @@ pub struct AlbumId3 { pub songs: Vec, } +#[allow(clippy::trivially_copy_pass_by_ref)] +fn album_id(id: &i32, s: S) -> Result { + let str = format!("al-{id}"); + + s.serialize_str(&str) +} + #[derive(Debug, Clone, Serialize, Default)] #[serde(default)] pub struct Child { #[serde(rename = "@id")] - pub id: i32, + pub id: String, #[serde(rename = "@parent", skip_serializing_if = "Option::is_none")] pub parent: Option, #[serde(rename = "@isDir")]