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