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