diff --git a/src/storage/file/id.rs b/src/storage/file/id.rs index 85aa1c49..c329aebb 100644 --- a/src/storage/file/id.rs +++ b/src/storage/file/id.rs @@ -9,48 +9,6 @@ use regex::Regex; use storage::file::hash::FileHash; -#[derive(Debug)] -#[derive(Clone)] -#[derive(PartialEq)] -#[derive(Eq)] -// #[derive(Display)] -pub enum FileIDType { - NONE, - UUID, -} - -impl Into for FileIDType { - - fn into(self) -> String { - let s = match self { - FileIDType::UUID => "UUID", - FileIDType::NONE => "", - }; - - String::from(s) - } - -} - -impl<'a> From<&'a str> for FileIDType { - - fn from(s: &'a str) -> FileIDType { - match s { - "UUID" => FileIDType::UUID, - _ => FileIDType::NONE, - } - } - -} - -impl From for FileIDType { - - fn from(s: String) -> FileIDType { - FileIDType::from(&s[..]) - } - -} - #[derive(Clone)] pub struct FileID { id: Option, diff --git a/src/storage/file/id_type.rs b/src/storage/file/id_type.rs new file mode 100644 index 00000000..b0ea7dee --- /dev/null +++ b/src/storage/file/id_type.rs @@ -0,0 +1,57 @@ +use std::convert::{From, Into}; +use std::error::Error; + +#[derive(Debug)] +#[derive(Clone)] +#[derive(PartialEq)] +#[derive(Eq)] +// #[derive(Display)] +pub enum FileIDType { + NONE, + UUID, +} + +impl Into for FileIDType { + + fn into(self) -> String { + into_string(&self) + } + +} + +impl<'a> From<&'a FileIDType> for String { + + fn from(t: &'a FileIDType) -> String { + into_string(t) + } + +} + +fn into_string(t: &FileIDType) -> String { + let s = match t { + &FileIDType::UUID => "UUID", + &FileIDType::NONE => "", + }; + + String::from(s) +} + +impl<'a> From<&'a str> for FileIDType { + + fn from(s: &'a str) -> FileIDType { + match s { + "UUID" => FileIDType::UUID, + _ => FileIDType::NONE, + } + } + +} + +impl From for FileIDType { + + fn from(s: String) -> FileIDType { + FileIDType::from(&s[..]) + } + +} +