1use crate::rpc::RpcResponseArguments;
2use crate::utils::string_fallback;
3
4#[derive(Deserialize, Debug, Default, PartialEq, Clone)]
8#[serde(rename_all = "camelCase")]
9#[serde(default)]
10pub struct Torrent {
11 pub id: i32,
12 pub activity_date: i32,
13 pub added_date: i32,
14 pub bandwidth_priority: i32,
15 pub comment: String,
16 pub corrupt_ever: i64,
17 pub creator: String,
18 pub date_created: i32,
19 pub desired_available: i64,
20 pub done_date: i32,
21 pub download_dir: String,
22 pub download_limit: i32,
23 pub download_limited: bool,
24 pub downloaded_ever: i64,
25 pub edit_date: i32,
26 pub error: i32,
27 pub error_string: String,
28 pub eta: i64,
29 pub eta_idle: i64,
30 pub hash_string: String,
31 pub have_unchecked: i64,
32 pub have_valid: i64,
33 pub honors_session_limits: bool,
34 pub is_finished: bool,
35 pub is_private: bool,
36 pub is_stalled: bool,
37 pub left_until_done: i64,
39 pub magnet_link: String,
40 pub manual_announce_time: i32,
41 pub metadata_percent_complete: f32,
42 pub name: String,
43 pub percent_done: f32,
44 pub piece_count: i64,
45 pub piece_size: i64,
46 pub pieces: String,
47 #[serde(rename = "primary-mime-type")]
48 #[serde(deserialize_with = "string_fallback")]
49 pub primary_mime_type: String,
50 pub queue_position: i32,
51 pub rate_download: i32,
52 pub rate_upload: i32,
53 pub recheck_progress: f32,
54 pub seconds_downloading: i32,
55 pub seconds_seeding: i32,
56 pub seed_idle_limit: i32,
57 pub seed_idle_mode: i32,
58 pub seed_ratio_limit: f32,
59 pub seed_ratio_mode: i32,
60 pub size_when_done: i64,
61 pub start_date: i32,
62 pub status: i32,
63 pub torrent_file: String,
64 pub total_size: i64,
65 pub upload_limit: i32,
66 pub upload_limited: bool,
67 pub upload_ratio: f32,
68 pub uploaded_ever: i64,
69}
70
71#[derive(Deserialize, Debug)]
72pub struct TorrentList {
73 pub torrents: Vec<Torrent>,
74}
75
76#[derive(Serialize, Debug, Clone, Default)]
77#[serde(rename_all = "camelCase")]
78pub struct TorrentMutator {
79 #[serde(skip_serializing_if = "Option::is_none")]
80 pub bandwidth_priority: Option<i32>,
81 #[serde(skip_serializing_if = "Option::is_none")]
82 pub download_limit: Option<i32>,
83 #[serde(skip_serializing_if = "Option::is_none")]
84 pub download_limited: Option<bool>,
85 #[serde(skip_serializing_if = "Option::is_none")]
86 #[serde(rename = "files-wanted")]
87 pub files_wanted: Option<Vec<i32>>,
88 #[serde(skip_serializing_if = "Option::is_none")]
89 #[serde(rename = "files-unwanted")]
90 pub files_unwanted: Option<Vec<i32>>,
91 #[serde(skip_serializing_if = "Option::is_none")]
92 pub honors_session_limits: Option<bool>,
93 #[serde(skip_serializing_if = "Option::is_none")]
96 pub location: Option<String>,
97 #[serde(skip_serializing_if = "Option::is_none")]
98 #[serde(rename = "peer-limit")]
99 pub peer_limit: Option<i32>,
100 #[serde(skip_serializing_if = "Option::is_none")]
110 pub queue_position: Option<i32>,
111 #[serde(skip_serializing_if = "Option::is_none")]
112 pub seed_idle_limit: Option<i32>,
113 #[serde(skip_serializing_if = "Option::is_none")]
114 pub seed_idle_mode: Option<i32>,
115 #[serde(skip_serializing_if = "Option::is_none")]
116 pub seed_ratio_limit: Option<f32>,
117 #[serde(skip_serializing_if = "Option::is_none")]
118 pub seed_ratio_mode: Option<i32>,
119 #[serde(skip_serializing_if = "Option::is_none")]
126 pub upload_limit: Option<i32>,
127 #[serde(skip_serializing_if = "Option::is_none")]
128 pub upload_limited: Option<bool>,
129}
130
131#[derive(Deserialize, Debug)]
132#[serde(rename_all = "kebab-case")]
133pub struct TorrentAdded {
134 pub torrent_added: Option<Torrent>,
135 pub torrent_duplicate: Option<Torrent>,
136}
137
138#[derive(Deserialize, Debug, Default, PartialEq, Clone)]
142#[serde(rename_all = "camelCase")]
143#[serde(default)]
144pub struct TorrentFiles {
145 pub id: i32,
146 #[serde(rename = "file-count")]
147 pub file_count: i32,
148 pub files: Vec<File>,
149 pub file_stats: Vec<FileStat>,
150 pub wanted: Vec<i32>,
151 pub priorities: Vec<i32>,
152}
153
154#[derive(Deserialize, Debug)]
155pub struct TorrentFilesList {
156 pub torrents: Vec<TorrentFiles>,
157}
158
159#[derive(Deserialize, Debug, Default, PartialEq, Clone)]
160#[serde(rename_all = "camelCase")]
161pub struct File {
162 pub bytes_completed: i64,
163 pub length: i64,
164 pub name: String,
165}
166
167#[derive(Deserialize, Debug, Default, PartialEq, Clone)]
168#[serde(rename_all = "camelCase")]
169pub struct FileStat {
170 pub bytes_completed: i64,
171 pub wanted: bool,
172 pub priority: i32,
173}
174
175#[derive(Deserialize, Debug, Default, PartialEq, Clone)]
179#[serde(rename_all = "camelCase")]
180#[serde(default)]
181pub struct TorrentPeers {
182 pub id: i32,
183 #[serde(rename = "peer-limit")]
184 pub peer_limit: i32,
185 pub peers_connected: i32,
187 pub peers_getting_from_us: i32,
189 pub peers_sending_to_us: i32,
190 pub max_connected_peers: i32,
191 pub webseeds_sending_to_us: i32,
192 }
194
195#[derive(Deserialize, Debug)]
196pub struct TorrentPeersList {
197 pub torrents: Vec<TorrentPeers>,
198}
199
200#[derive(Deserialize, Debug, Default, PartialEq, Clone)]
204#[serde(rename_all = "camelCase")]
205#[serde(default)]
206pub struct TorrentTrackers {
207 pub id: i32,
208 }
211
212#[derive(Deserialize, Debug)]
213pub struct TorrentTrackersList {
214 pub torrents: Vec<TorrentTrackers>,
215}
216
217impl RpcResponseArguments for Torrent {}
218impl RpcResponseArguments for TorrentList {}
219impl RpcResponseArguments for TorrentAdded {}
220impl RpcResponseArguments for TorrentFiles {}
221impl RpcResponseArguments for TorrentFilesList {}
222impl RpcResponseArguments for TorrentPeers {}
223impl RpcResponseArguments for TorrentPeersList {}
224impl RpcResponseArguments for TorrentTrackers {}
225impl RpcResponseArguments for TorrentTrackersList {}