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