Major early updates
This commit is contained in:
166
frontend/src/types.rs
Normal file
166
frontend/src/types.rs
Normal file
@@ -0,0 +1,166 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// --- Library entities ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||
pub struct Artist {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub musicbrainz_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||
pub struct Album {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub album_artist: String,
|
||||
pub year: Option<i32>,
|
||||
pub genre: Option<String>,
|
||||
pub musicbrainz_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||
pub struct Track {
|
||||
pub id: i32,
|
||||
pub file_path: String,
|
||||
pub title: Option<String>,
|
||||
pub artist: Option<String>,
|
||||
pub album: Option<String>,
|
||||
pub track_number: Option<i32>,
|
||||
pub year: Option<i32>,
|
||||
pub genre: Option<String>,
|
||||
pub codec: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct ArtistDetail {
|
||||
pub artist: Artist,
|
||||
pub albums: Vec<Album>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct AlbumDetail {
|
||||
pub album: Album,
|
||||
pub tracks: Vec<Track>,
|
||||
}
|
||||
|
||||
// --- Search results ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct ArtistResult {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub disambiguation: Option<String>,
|
||||
pub country: Option<String>,
|
||||
pub artist_type: Option<String>,
|
||||
pub score: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct AlbumResult {
|
||||
pub id: String,
|
||||
pub title: String,
|
||||
pub artist: String,
|
||||
pub artist_id: Option<String>,
|
||||
pub year: Option<String>,
|
||||
pub track_count: Option<i32>,
|
||||
pub score: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct TrackResult {
|
||||
pub id: String,
|
||||
pub title: String,
|
||||
pub artist: String,
|
||||
pub artist_id: Option<String>,
|
||||
pub album: Option<String>,
|
||||
pub score: u8,
|
||||
}
|
||||
|
||||
// --- Watchlist ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct WatchListEntry {
|
||||
pub id: i32,
|
||||
pub item_type: String,
|
||||
pub name: String,
|
||||
pub artist_name: Option<String>,
|
||||
pub status: String,
|
||||
}
|
||||
|
||||
// --- Downloads ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct DownloadItem {
|
||||
pub id: i32,
|
||||
pub query: String,
|
||||
pub status: String,
|
||||
pub source_url: Option<String>,
|
||||
pub error_message: Option<String>,
|
||||
pub retry_count: i32,
|
||||
}
|
||||
|
||||
// --- Tasks ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct TaskInfo {
|
||||
pub id: String,
|
||||
pub task_type: String,
|
||||
pub status: String,
|
||||
pub result: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct TaskRef {
|
||||
pub task_id: String,
|
||||
}
|
||||
|
||||
// --- Status ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct Status {
|
||||
pub library: LibrarySummary,
|
||||
pub queue: QueueStatus,
|
||||
pub tasks: Vec<TaskInfo>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct LibrarySummary {
|
||||
pub total_items: u64,
|
||||
pub wanted: u64,
|
||||
pub available: u64,
|
||||
pub downloaded: u64,
|
||||
pub owned: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct QueueStatus {
|
||||
pub pending: usize,
|
||||
pub downloading: usize,
|
||||
}
|
||||
|
||||
// --- API responses ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct AddSummary {
|
||||
pub tracks_added: u64,
|
||||
pub tracks_already_owned: u64,
|
||||
pub errors: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct SyncStats {
|
||||
pub found: u64,
|
||||
pub enqueued: u64,
|
||||
pub skipped: u64,
|
||||
}
|
||||
|
||||
// --- Config ---
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
pub struct AppConfig {
|
||||
pub library_path: String,
|
||||
pub database_url: String,
|
||||
pub download_path: String,
|
||||
pub organization_format: String,
|
||||
}
|
||||
Reference in New Issue
Block a user