tauri_plugin_apple_music_kit/
models.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4#[serde(rename_all = "camelCase")]
5pub struct MusicKitTrack {
6    pub id: String,
7    pub title: String,
8    pub artist: String,
9    pub album: String,
10    pub duration: f64,
11    pub artwork_url: Option<String>,
12    pub is_explicit: bool,
13    pub is_playable: bool,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17#[serde(rename_all = "camelCase")]
18pub struct AuthorizationResponse {
19    pub status: String, // "authorized", "notAuthorized", "error"
20    pub error: Option<String>,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
24#[serde(rename_all = "camelCase")]
25pub struct UnauthorizeResponse {
26    pub status: String, // "unauthorized", "error"
27    pub error: Option<String>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(rename_all = "camelCase")]
32pub struct AuthorizationStatusResponse {
33    pub status: String, // "authorized", "notAuthorized", "notInitialized"
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(rename_all = "camelCase")]
38pub struct QueueResponse {
39    pub items: Vec<MusicKitTrack>,
40    pub position: usize,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(rename_all = "camelCase")]
45pub struct QueueOperationResponse {
46    pub success: bool,
47    pub error: Option<String>,
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(rename_all = "camelCase")]
52pub struct StateUpdateEvent {
53    pub playing: bool,
54    pub current_track: Option<MusicKitTrack>,
55    pub current_time: f64,
56    pub duration: f64,
57    pub queue_position: usize,
58    pub shuffle_mode: String,
59    pub repeat_mode: String,
60    pub volume: f64,
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(rename_all = "camelCase")]
65pub struct QueueUpdateEvent {
66    pub items: Vec<MusicKitTrack>,
67    pub position: usize,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(rename_all = "camelCase")]
72pub struct TrackChangeEvent {
73    pub track: MusicKitTrack,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(rename_all = "camelCase")]
78pub struct ErrorEvent {
79    pub error: String,
80    pub code: Option<String>,
81}