1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use std::{collections::HashMap, net::SocketAddr};

use serde_value::Value;

use crate::model::{Category, Torrent};

#[derive(Debug, Clone, serde::Deserialize, PartialEq)]
pub struct SyncData {
    /// Response ID
    pub rid: i64,
    /// Whether the response contains all the data or partial data
    pub full_update: bool,
    /// Property: torrent hash, value: same as [torrent list](#get-torrent-list)
    pub torrents: Option<HashMap<String, Torrent>>,
    /// List of hashes of torrents removed since last request
    pub torrents_removed: Option<Vec<String>>,
    /// Info for categories added since last request
    pub categories: Option<HashMap<String, Category>>,
    /// List of categories removed since last request
    pub categories_removed: Option<Vec<String>>,
    /// List of tags added since last request
    pub tags: Option<Vec<String>>,
    /// List of tags removed since last request
    pub tags_removed: Option<Vec<String>>,
    /// Global transfer info
    pub server_state: Option<HashMap<String, Value>>,
}

#[derive(Debug, Clone, serde::Deserialize, PartialEq)]
pub struct PeerSyncData {
    pub full_update: bool,
    pub peers: HashMap<SocketAddr, Peer>,
    pub rid: i64,
    pub show_flags: bool,
}
#[derive(Debug, Clone, serde::Deserialize, PartialEq)]
pub struct Peer {
    pub client: Option<String>,
    pub connection: Option<String>,
    pub country: Option<String>,
    pub country_code: Option<String>,
    pub dl_speed: Option<u64>,
    pub downloaded: Option<u64>,
    pub files: Option<String>,
    pub flags: Option<String>,
    pub flags_desc: Option<String>,
    pub ip: Option<String>,
    pub port: Option<u16>,
    pub progress: Option<u64>,
    pub relevance: Option<u64>,
    pub up_speed: Option<u64>,
    pub uploaded: Option<u64>,
}