updated enum iterator

This commit is contained in:
Aleksandr Bochev 2022-10-02 17:29:09 +02:00 committed by Aleksandr
parent c35410dc7b
commit f39a6eb1d4
2 changed files with 5 additions and 11 deletions

View File

@ -17,7 +17,7 @@ reqwest = { version = "0.11.11", features = [
"rustls-tls",
], default-features = false }
serde = { version = "1.0.144", features = ["derive"] }
enum-iterator = "0.8.1"
enum-iterator = "1.2.0"
dotenvy = "0.15.5"
log = "0.4.17"

View File

@ -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(TorrentGetField::all())
.unwrap_or(all::<TorrentGetField>().collect())
.iter()
.map(TorrentGetField::to_str)
.collect();
@ -155,9 +155,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,
@ -239,7 +237,7 @@ pub struct TorrentAddArgs {
pub labels: Option<Vec<String>>,
}
#[derive(Clone, Copy, IntoEnumIterator)]
#[derive(Clone, Copy, Sequence)]
pub enum TorrentGetField {
ActivityDate,
AddedDate,
@ -283,10 +281,6 @@ pub enum TorrentGetField {
}
impl TorrentGetField {
pub fn all() -> Vec<TorrentGetField> {
TorrentGetField::into_enum_iter().collect()
}
#[must_use]
pub fn to_str(&self) -> String {
match self {