From 07e1080e91179a315cc3409a343e74763e41c245 Mon Sep 17 00:00:00 2001 From: TANIGUCHI Takaki Date: Mon, 20 Nov 2023 16:24:56 +0900 Subject: [PATCH] add trackerStats and trackerList to torrent-get params --- src/types/request.rs | 8 ++++++-- src/types/response.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/types/request.rs b/src/types/request.rs index 6f1a7e0..4271342 100644 --- a/src/types/request.rs +++ b/src/types/request.rs @@ -1,5 +1,5 @@ use enum_iterator::{all, Sequence}; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; #[derive(Serialize, Debug)] @@ -414,7 +414,7 @@ pub struct TorrentRenamePathArgs { name: String, } -#[derive(Serialize, Debug, Clone)] +#[derive(Deserialize, Serialize, Debug, Clone)] #[serde(untagged)] pub enum Id { Id(i64), @@ -511,6 +511,8 @@ pub enum TorrentGetField { TorrentFile, TotalSize, Trackers, + TrackerList, + TrackerStats, UploadRatio, UploadedEver, Wanted, @@ -559,6 +561,8 @@ impl TorrentGetField { TorrentGetField::TorrentFile => "torrentFile", TorrentGetField::TotalSize => "totalSize", TorrentGetField::Trackers => "trackers", + TorrentGetField::TrackerList => "trackerList", + TorrentGetField::TrackerStats => "trackerStats", TorrentGetField::UploadRatio => "uploadRatio", TorrentGetField::UploadedEver => "uploadedEver", TorrentGetField::Wanted => "wanted", diff --git a/src/types/response.rs b/src/types/response.rs index 15a9afb..9d2e242 100644 --- a/src/types/response.rs +++ b/src/types/response.rs @@ -130,6 +130,8 @@ pub struct Torrent { pub torrent_file: Option, pub total_size: Option, pub trackers: Option>, + pub tracker_list: Option, + pub tracker_stats: Option>, pub upload_ratio: Option, pub uploaded_ever: Option, pub files: Option>, @@ -189,6 +191,47 @@ pub struct FileStat { pub priority: Priority, } +#[derive(Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct TrackerStat { + pub announce_state: TrackerState, + pub announce: String, + pub download_count: i64, + pub has_announced: bool, + pub has_scraped: bool, + pub host: String, + pub id: Id, + pub is_backup: bool, + pub last_announce_peer_count: i64, + pub last_announce_result: String, + pub last_announce_start_time: i64, + pub last_announce_succeeded: bool, + pub last_announce_time: i64, + pub last_announce_timed_out: bool, + pub last_scrape_result: String, + pub last_scrape_start_time: i64, + pub last_scrape_succeeded: bool, + pub last_scrape_time: i64, + pub last_scrape_timed_out: bool, + pub leecher_count: i64, + pub next_announce_time: i64, + pub next_scrape_time: i64, + pub scrape_state: TrackerState, + pub scrape: String, + pub seeder_count: i64, + pub sitename: String, + pub tier: usize, +} + +#[derive(Deserialize_repr, Debug, Clone)] +#[repr(i8)] +pub enum TrackerState { + Inactive = 0, + Waiting = 1, + Queued = 2, + Active = 3, +} + #[derive(Deserialize, Debug)] pub struct Nothing {} impl RpcResponseArgument for Nothing {}