From 27ec3b98f0dc6a4c742e6cfea633104196e8303c Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 14 Aug 2021 12:41:22 +0200 Subject: [PATCH] Refactor hydrus file Signed-off-by: trivernis --- src/wrapper/hydrus_file.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/wrapper/hydrus_file.rs b/src/wrapper/hydrus_file.rs index 12036cc..a0312ea 100644 --- a/src/wrapper/hydrus_file.rs +++ b/src/wrapper/hydrus_file.rs @@ -18,6 +18,16 @@ pub enum FileStatus { impl Eq for FileStatus {} +impl From for FileStatus { + fn from(v: u8) -> FileStatus { + match v { + 3 => FileStatus::Deleted, + 0 => FileStatus::ReadyForImport, + _ => FileStatus::InDatabase, + } + } +} + #[derive(Clone)] pub struct HydrusFile { pub(crate) client: Client, @@ -41,17 +51,10 @@ impl HydrusFile { status: u8, hash: S, ) -> Self { - let status = if status == 3 { - FileStatus::Deleted - } else if status == 0 { - FileStatus::ReadyForImport - } else { - FileStatus::InDatabase - }; Self { client, id: FileIdentifier::Hash(hash.to_string()), - status, + status: status.into(), metadata: None, } }