Refactor hydrus file

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/6/head
trivernis 3 years ago
parent 5ffae11044
commit 27ec3b98f0
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -18,6 +18,16 @@ pub enum FileStatus {
impl Eq for FileStatus {} impl Eq for FileStatus {}
impl From<u8> for FileStatus {
fn from(v: u8) -> FileStatus {
match v {
3 => FileStatus::Deleted,
0 => FileStatus::ReadyForImport,
_ => FileStatus::InDatabase,
}
}
}
#[derive(Clone)] #[derive(Clone)]
pub struct HydrusFile { pub struct HydrusFile {
pub(crate) client: Client, pub(crate) client: Client,
@ -41,17 +51,10 @@ impl HydrusFile {
status: u8, status: u8,
hash: S, hash: S,
) -> Self { ) -> Self {
let status = if status == 3 {
FileStatus::Deleted
} else if status == 0 {
FileStatus::ReadyForImport
} else {
FileStatus::InDatabase
};
Self { Self {
client, client,
id: FileIdentifier::Hash(hash.to_string()), id: FileIdentifier::Hash(hash.to_string()),
status, status: status.into(),
metadata: None, metadata: None,
} }
} }

Loading…
Cancel
Save