mirror of
https://github.com/kristoferssolo/transmission-rpc.git
synced 2025-10-21 20:10:37 +00:00
Cargo upgrade, IntoEnumIterator -> Sequence
This commit is contained in:
parent
3b2adef3bf
commit
6d12272018
12
Cargo.toml
12
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"] }
|
||||
|
||||
@ -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<Vec<TorrentGetField>>, ids: Option<Vec<Id>>) -> RpcRequest {
|
||||
let string_fields = fields
|
||||
.unwrap_or_else(TorrentGetField::all)
|
||||
.unwrap_or(all::<TorrentGetField>().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::<TorrentGetField>().map(|it| it.to_str()).collect();
|
||||
TorrentGetArgs {
|
||||
fields: Some(all_fields),
|
||||
ids: None,
|
||||
@ -228,7 +226,26 @@ pub struct TorrentAddArgs {
|
||||
pub priority_normal: Option<Vec<i32>>,
|
||||
}
|
||||
|
||||
#[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> {
|
||||
TorrentGetField::into_enum_iter().collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl TorrentGetField {
|
||||
#[must_use]
|
||||
pub fn to_str(&self) -> String {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user