1mod albums;
2mod artists;
3pub mod auth;
4pub mod batch;
5mod favourites;
6pub mod lyrics;
7pub mod playback_state;
8pub mod radio;
9mod scan_cache;
10mod search;
11pub mod snapshots;
12mod stats;
13pub mod tracks;
14pub mod vectors;
15
16use std::path::PathBuf;
17
18pub use albums::*;
20pub use artists::*;
21pub use batch::*;
22pub use favourites::*;
23pub use lyrics::*;
24pub use playback_state::*;
25pub use radio::*;
26pub use scan_cache::*;
27pub use search::*;
28pub use snapshots::*;
29pub use stats::*;
30pub use tracks::*;
31pub use vectors::*;
32
33#[derive(Debug, Clone)]
36pub struct ArtistRow {
37 pub id: i64,
38 pub name: String,
39 pub sort_name: Option<String>,
40 pub remote_id: Option<String>,
41 pub album_count: i64,
45 pub track_count: i64,
46}
47
48#[derive(Debug, Clone)]
49pub struct AlbumRow {
50 pub id: i64,
51 pub title: String,
52 pub artist_id: i64,
53 pub artist_name: String,
54 pub date: Option<String>,
55 pub total_discs: Option<i32>,
56 pub total_tracks: Option<i32>,
57 pub codec: Option<String>,
58 pub label: Option<String>,
59 pub remote_id: Option<String>,
60 pub added_at: Option<String>,
63}
64
65#[derive(Debug, Clone)]
66pub struct TrackRow {
67 pub id: i64,
68 pub album_id: Option<i64>,
69 pub artist_id: Option<i64>,
70 pub artist_name: String,
71 pub album_artist_name: String,
72 pub album_title: String,
73 pub disc: Option<i32>,
74 pub track_number: Option<i32>,
75 pub title: String,
76 pub duration_ms: Option<i64>,
77 pub path: Option<String>,
78 pub codec: Option<String>,
79 pub sample_rate: Option<i32>,
80 pub bit_depth: Option<i32>,
81 pub channels: Option<i32>,
82 pub bitrate: Option<i32>,
83 pub genre: Option<String>,
84 pub source: String,
85 pub remote_id: Option<String>,
86 pub cached_path: Option<String>,
87}
88
89#[derive(Debug, Clone)]
91pub enum PlaybackSource {
92 Local(PathBuf),
93 Cached(PathBuf),
94 Remote(String),
95}
96
97#[derive(Debug, Clone, Default)]
98pub struct LibraryStats {
99 pub total_tracks: i64,
100 pub local_tracks: i64,
101 pub remote_tracks: i64,
102 pub cached_tracks: i64,
103 pub total_albums: i64,
104 pub total_artists: i64,
105}
106
107#[derive(Debug, Clone)]
109pub struct TrackMeta {
110 pub title: String,
111 pub artist: String,
112 pub album_artist: Option<String>,
113 pub album: String,
114 pub date: Option<String>,
115 pub disc: Option<i32>,
116 pub track_number: Option<i32>,
117 pub genre: Option<String>,
118 pub label: Option<String>,
119 pub duration_ms: Option<i64>,
120 pub codec: Option<String>,
121 pub sample_rate: Option<i32>,
122 pub bit_depth: Option<i32>,
123 pub channels: Option<i32>,
124 pub bitrate: Option<i32>,
125 pub size_bytes: Option<i64>,
126 pub mtime: Option<i64>,
127 pub path: Option<String>,
128 pub source: String,
129 pub remote_id: Option<String>,
130 pub remote_url: Option<String>,
131 pub album_added_at: Option<String>,
135}
136
137#[cfg(test)]
139pub fn sample_meta(title: &str, artist: &str, album: &str) -> TrackMeta {
140 TrackMeta {
141 title: title.into(),
142 artist: artist.into(),
143 album_artist: Some(artist.into()),
144 album: album.into(),
145 date: Some("2024".into()),
146 disc: Some(1),
147 track_number: Some(1),
148 genre: Some("Electronic".into()),
149 label: None,
150 duration_ms: Some(240_000),
151 codec: Some("FLAC".into()),
152 sample_rate: Some(44100),
153 bit_depth: Some(16),
154 channels: Some(2),
155 bitrate: Some(1000),
156 size_bytes: Some(30_000_000),
157 mtime: Some(1700000000),
158 path: Some(format!("/music/{}/{}.flac", album, title)),
159 source: "local".into(),
160 remote_id: None,
161 remote_url: None,
162 album_added_at: None,
163 }
164}