Update SongData for frontend use

This commit is contained in:
2024-07-23 23:31:48 -04:00
parent ffad799f72
commit f8bbe319bd
3 changed files with 28 additions and 11 deletions

View File

@ -1,12 +1,26 @@
use crate::database;
use crate::models::{Album, Artist, Song};
use time::Date;
/// Holds information about a song
#[derive(Debug, Clone)]
///
/// Intended to be used in the front-end, as it includes artist and album objects, rather than just their ids.
pub struct SongData {
/// Song id
pub id: i32,
/// Song name
pub name: String,
/// Song artist
pub artist: String,
pub title: String,
/// Song artists
pub artists: Vec<Artist>,
/// Song album
pub album: String,
pub album: Option<Album>,
/// The track number of the song on the album
pub track: Option<i32>,
/// The duration of the song in seconds
pub duration: i32,
/// The song's release date
pub release_date: Option<Date>,
/// Path to song file, relative to the root of the web server.
/// For example, `"/assets/audio/Song.mp3"`
pub song_path: String,