From 6d122720188c2cde86b52ecd65a1d6e0ac79f49b Mon Sep 17 00:00:00 2001 From: Leopith <113810806+leopith@users.noreply.github.com> Date: Mon, 19 Sep 2022 10:46:51 +1000 Subject: [PATCH] Cargo upgrade, IntoEnumIterator -> Sequence --- Cargo.toml | 12 ++++++------ src/types/request.rs | 36 +++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 03be7f3..82aebdf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,16 +12,16 @@ categories = ["api-bindings"] include = ["**/*.rs", "Cargo.toml"] [dependencies] -reqwest = { version = "0.11.2", features = [ +reqwest = { version = "0.11.11", features = [ "json", "rustls-tls", ], default-features = false } -serde = { version = "1.0.124", features = ["derive"] } -enum-iterator = "0.8.1" +serde = { version = "1.0.144", features = ["derive"] } +enum-iterator = "1.2.0" dotenv = "0.15.0" -log = "0.4.14" -env_logger = "0.9.0" +log = "0.4.17" +env_logger = "0.9.1" [dev-dependencies] -tokio = { version = "1.3.0", features = ["macros", "rt-multi-thread"] } +tokio = { version = "1.21.1", features = ["macros", "rt-multi-thread"] } diff --git a/src/types/request.rs b/src/types/request.rs index ee98d51..a81b1b8 100644 --- a/src/types/request.rs +++ b/src/types/request.rs @@ -1,4 +1,4 @@ -use enum_iterator::IntoEnumIterator; +use enum_iterator::{all, Sequence}; use serde::Serialize; #[derive(Serialize, Debug)] @@ -53,7 +53,7 @@ impl RpcRequest { pub fn torrent_get(fields: Option>, ids: Option>) -> RpcRequest { let string_fields = fields - .unwrap_or_else(TorrentGetField::all) + .unwrap_or(all::().collect()) .iter() .map(TorrentGetField::to_str) .collect(); @@ -146,9 +146,7 @@ pub struct TorrentGetArgs { impl Default for TorrentGetArgs { fn default() -> Self { - let all_fields = TorrentGetField::into_enum_iter() - .map(|it| it.to_str()) - .collect(); + let all_fields = all::().map(|it| it.to_str()).collect(); TorrentGetArgs { fields: Some(all_fields), ids: None, @@ -228,7 +226,26 @@ pub struct TorrentAddArgs { pub priority_normal: Option>, } -#[derive(Clone, Copy, IntoEnumIterator)] +impl Default for TorrentAddArgs { + fn default() -> Self { + TorrentAddArgs { + cookies: None, + download_dir: None, + filename: None, + metainfo: None, + paused: None, + peer_limit: None, + bandwidth_priority: None, + files_wanted: None, + files_unwanted: None, + priority_high: None, + priority_low: None, + priority_normal: None, + } + } +} + +#[derive(Clone, Sequence)] pub enum TorrentGetField { AddedDate, DoneDate, @@ -266,13 +283,6 @@ pub enum TorrentGetField { WebseedsSendingToUs, } -impl TorrentGetField { - #[must_use] - pub fn all() -> Vec { - TorrentGetField::into_enum_iter().collect() - } -} - impl TorrentGetField { #[must_use] pub fn to_str(&self) -> String {