1use serde::{Deserialize, Serialize};
2use ts_rs::TS;
3
4#[derive(TS, Serialize, Deserialize, Debug, Clone)]
10#[ts(export)]
11pub struct Movie {
12 pub title: String,
13 pub year: i32,
14 pub size: i64,
15 pub hash: String,
16 pub tmdb_id: i32,
17 pub audio_languages: String,
18 pub subtitle_languages: String,
19 pub resolution: String,
20 pub dynamic_range: String,
21 pub bitrate: i32,
22}
23
24#[derive(TS, Serialize, Deserialize, Debug, Clone)]
25#[ts(export)]
26pub struct LoginCredentials {
27 pub username: String,
28 pub password: String,
29}
30
31#[derive(TS, Serialize, Deserialize, Debug, Clone)]
32#[ts(export)]
33pub struct PushMovies {
34 pub username: String,
35 pub api_key: String,
36 pub movies: Vec<Movie>,
37}
38
39#[derive(TS, Serialize, Deserialize, Debug, Clone)]
40#[ts(export)]
41pub struct GetTMDbApiKey {
42 pub username: String,
43 pub api_key: String,
44}
45
46#[derive(TS, Serialize, Deserialize, Debug, Clone)]
47#[ts(export)]
48pub struct GetTMDbApiKeyResult {
49 pub tmdb_api_key: Option<String>,
50}
51
52#[derive(TS, Serialize, Deserialize, Debug, Clone)]
53#[ts(export)]
54pub struct Session {
55 pub username: String,
56 pub api_key: String,
57}
58
59#[derive(TS, Serialize, Deserialize, Debug, Clone)]
60#[ts(export)]
61pub struct InvalidData {
62 pub data: String,
63 pub error_msg: String,
64}
65
66#[derive(TS, Serialize, Deserialize, Debug, Clone)]
67#[ts(export)]
68pub struct LoginFailed {
69 pub reason: String,
70}
71
72#[derive(TS, Serialize, Deserialize, Debug, Clone)]
73#[ts(export)]
74pub struct PushMoviesResult {
75 pub success: bool,
76 pub reason: String,
77}
78
79#[derive(TS, Serialize, Deserialize, Debug, Clone)]
81#[serde(tag = "type")]
82#[ts(export)]
83pub enum MendiaReply {
84 NotImplemented { command: String },
85 InvalidData(InvalidData),
86 LoginFailed(LoginFailed),
87 Session(Session),
88 Movies { movies: Vec<Movie> },
89 PushMoviesResult(PushMoviesResult),
90 GetTMDbApiKeyResult(GetTMDbApiKeyResult),
91}
92
93#[derive(TS, Serialize, Deserialize, Debug, Clone)]
95#[serde(tag = "type")]
96#[ts(export)]
97pub enum MendiaRequest {
98 LoginCredentials(LoginCredentials),
99 GetMovies { user: String },
100 PushMovies(PushMovies),
101 GetTMDbApiKey(GetTMDbApiKey),
102}