From 78c99808444c167586b672b752d321df04583d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quang=20Ng=C3=B4?= Date: Mon, 15 Nov 2021 23:23:00 +0700 Subject: [PATCH] Remove deprecated `rustc-serialize` --- Cargo.toml | 1 - src/types/request.rs | 20 ++++++++++---------- src/types/response.rs | 16 ++++++++-------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b176aa0..6934756 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ include = [ [dependencies] reqwest = { version = "0.11.2", features = ["json", "rustls-tls"], default-features = false } serde = { version = "1.0.124", features = ["derive"] } -rustc-serialize = "0.3.24" enum-iterator = "0.7.0" dotenv = "0.15.0" diff --git a/src/types/request.rs b/src/types/request.rs index 97ba4b5..6e7f4d1 100644 --- a/src/types/request.rs +++ b/src/types/request.rs @@ -1,7 +1,7 @@ use enum_iterator::IntoEnumIterator; use serde::Serialize; -#[derive(Serialize, Debug, RustcEncodable)] +#[derive(Serialize, Debug)] pub struct RpcRequest { method: String, #[serde(skip_serializing_if = "Option::is_none")] @@ -108,7 +108,7 @@ impl RpcRequest { pub trait ArgumentFields {} impl ArgumentFields for TorrentGetField {} -#[derive(Serialize, Debug, RustcEncodable, Clone)] +#[derive(Serialize, Debug, Clone)] #[serde(untagged)] pub enum Args { FreeSpaceArgs(FreeSpaceArgs), @@ -120,12 +120,12 @@ pub enum Args { TorrentRenamePathArgs(TorrentRenamePathArgs), } -#[derive(Serialize, Debug, RustcEncodable, Clone)] +#[derive(Serialize, Debug, Clone)] pub struct FreeSpaceArgs { path: String, } -#[derive(Serialize, Debug, RustcEncodable, Clone)] +#[derive(Serialize, Debug, Clone)] pub struct TorrentGetArgs { #[serde(skip_serializing_if = "Option::is_none")] fields: Option>, @@ -145,18 +145,18 @@ impl Default for TorrentGetArgs { } } -#[derive(Serialize, Debug, RustcEncodable, Clone)] +#[derive(Serialize, Debug, Clone)] pub struct TorrentActionArgs { ids: Vec, } -#[derive(Serialize, Debug, RustcEncodable, Clone)] +#[derive(Serialize, Debug, Clone)] pub struct TorrentRemoveArgs { ids: Vec, #[serde(rename = "delete-local-data")] delete_local_data: bool, } -#[derive(Serialize, Debug, RustcEncodable, Clone)] +#[derive(Serialize, Debug, Clone)] pub struct TorrentSetLocationArgs { ids: Vec, location: String, @@ -164,21 +164,21 @@ pub struct TorrentSetLocationArgs { move_from: Option, } -#[derive(Serialize, Debug, RustcEncodable, Clone)] +#[derive(Serialize, Debug, Clone)] pub struct TorrentRenamePathArgs { ids: Vec, path: String, name: String, } -#[derive(Serialize, Debug, RustcEncodable, Clone)] +#[derive(Serialize, Debug, Clone)] #[serde(untagged)] pub enum Id { Id(i64), Hash(String), } -#[derive(Serialize, Debug, RustcEncodable, Clone)] +#[derive(Serialize, Debug, Clone)] pub struct TorrentAddArgs { #[serde(skip_serializing_if = "Option::is_none")] pub cookies: Option, diff --git a/src/types/response.rs b/src/types/response.rs index 66369ba..de9e3db 100644 --- a/src/types/response.rs +++ b/src/types/response.rs @@ -68,7 +68,7 @@ pub struct PortTest { } impl RpcResponseArgument for PortTest {} -#[derive(Deserialize, Debug, RustcEncodable, Clone)] +#[derive(Deserialize, Debug, Clone)] pub struct Torrent { #[serde(rename = "addedDate")] pub added_date: Option, @@ -139,19 +139,19 @@ pub struct Stats { pub session_count: Option } -#[derive(Deserialize, Debug, RustcEncodable)] +#[derive(Deserialize, Debug)] pub struct Torrents { pub torrents: Vec, } impl RpcResponseArgument for Torrents {} -#[derive(Deserialize, Debug, RustcEncodable, Clone)] +#[derive(Deserialize, Debug, Clone)] pub struct Trackers { pub id: i32, pub announce: String, } -#[derive(Deserialize, Debug, RustcEncodable, Clone)] +#[derive(Deserialize, Debug, Clone)] pub struct File { pub length: i64, #[serde(rename = "bytesCompleted")] @@ -159,7 +159,7 @@ pub struct File { pub name: String, } -#[derive(Deserialize, Debug, RustcEncodable, Clone)] +#[derive(Deserialize, Debug, Clone)] pub struct FileStat { #[serde(rename = "bytesCompleted")] pub bytes_completed: i64, @@ -168,18 +168,18 @@ pub struct FileStat { pub priority: i8, } -#[derive(Deserialize, Debug, RustcEncodable)] +#[derive(Deserialize, Debug)] pub struct Nothing {} impl RpcResponseArgument for Nothing {} -#[derive(Deserialize, Debug, RustcEncodable)] +#[derive(Deserialize, Debug)] pub struct TorrentAdded { #[serde(rename = "torrent-added")] pub torrent_added: Option, } impl RpcResponseArgument for TorrentAdded {} -#[derive(Deserialize, Debug, RustcEncodable)] +#[derive(Deserialize, Debug)] pub struct TorrentRenamePath{ pub path: String, pub name: String,