From 4fe84956da6910bdacced13c1afbfbcb132b137f Mon Sep 17 00:00:00 2001 From: Leopith <113810806+leopith@users.noreply.github.com> Date: Sun, 1 Jan 2023 14:09:32 +1100 Subject: [PATCH] Enumify the torrent error type --- src/types/mod.rs | 5 +++-- src/types/response.rs | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/types/mod.rs b/src/types/mod.rs index 6b32d5a..9e35f96 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -17,6 +17,7 @@ pub use self::request::{ pub(crate) use self::response::RpcResponseArgument; pub use self::response::{ - BlocklistUpdate, FreeSpace, Nothing, PortTest, RpcResponse, SessionClose, SessionGet, - SessionStats, Torrent, TorrentAddedOrDuplicate, TorrentRenamePath, TorrentStatus, Torrents, + BlocklistUpdate, ErrorType, FreeSpace, Nothing, PortTest, RpcResponse, SessionClose, + SessionGet, SessionStats, Torrent, TorrentAddedOrDuplicate, TorrentRenamePath, TorrentStatus, + Torrents, }; diff --git a/src/types/response.rs b/src/types/response.rs index d5553ba..bcc4bf6 100644 --- a/src/types/response.rs +++ b/src/types/response.rs @@ -81,6 +81,15 @@ pub enum TorrentStatus { Seeding = 6, } +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Deserialize_repr)] +#[repr(u8)] +pub enum ErrorType { + Ok = 0, + TrackerWarning = 1, + TrackerError = 2, + LocalError = 3, +} + #[derive(Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct Torrent { @@ -89,7 +98,7 @@ pub struct Torrent { pub done_date: Option, pub download_dir: Option, pub edit_date: Option, - pub error: Option, + pub error: Option, pub error_string: Option, pub eta: Option, pub id: Option,