Remove deprecated rustc-serialize

This commit is contained in:
Quang Ngô 2021-11-15 23:23:00 +07:00 committed by Aleksandr
parent 2e9dbdf2cc
commit 78c9980844
3 changed files with 18 additions and 19 deletions

View File

@ -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"

View File

@ -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<Vec<String>>,
@ -145,18 +145,18 @@ impl Default for TorrentGetArgs {
}
}
#[derive(Serialize, Debug, RustcEncodable, Clone)]
#[derive(Serialize, Debug, Clone)]
pub struct TorrentActionArgs {
ids: Vec<Id>,
}
#[derive(Serialize, Debug, RustcEncodable, Clone)]
#[derive(Serialize, Debug, Clone)]
pub struct TorrentRemoveArgs {
ids: Vec<Id>,
#[serde(rename = "delete-local-data")]
delete_local_data: bool,
}
#[derive(Serialize, Debug, RustcEncodable, Clone)]
#[derive(Serialize, Debug, Clone)]
pub struct TorrentSetLocationArgs {
ids: Vec<Id>,
location: String,
@ -164,21 +164,21 @@ pub struct TorrentSetLocationArgs {
move_from: Option<bool>,
}
#[derive(Serialize, Debug, RustcEncodable, Clone)]
#[derive(Serialize, Debug, Clone)]
pub struct TorrentRenamePathArgs {
ids: Vec<Id>,
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<String>,

View File

@ -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<i64>,
@ -139,19 +139,19 @@ pub struct Stats {
pub session_count: Option<i32>
}
#[derive(Deserialize, Debug, RustcEncodable)]
#[derive(Deserialize, Debug)]
pub struct Torrents<T> {
pub torrents: Vec<T>,
}
impl RpcResponseArgument for Torrents<Torrent> {}
#[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<Torrent>,
}
impl RpcResponseArgument for TorrentAdded {}
#[derive(Deserialize, Debug, RustcEncodable)]
#[derive(Deserialize, Debug)]
pub struct TorrentRenamePath{
pub path: String,
pub name: String,