Move FileIDType to new module, export publicly
This commit is contained in:
parent
8a7d4b8aaf
commit
dcec155505
2 changed files with 57 additions and 42 deletions
|
@ -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<String> 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<String> for FileIDType {
|
||||
|
||||
fn from(s: String) -> FileIDType {
|
||||
FileIDType::from(&s[..])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct FileID {
|
||||
id: Option<FileHash>,
|
||||
|
|
57
src/storage/file/id_type.rs
Normal file
57
src/storage/file/id_type.rs
Normal file
|
@ -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<String> 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<String> for FileIDType {
|
||||
|
||||
fn from(s: String) -> FileIDType {
|
||||
FileIDType::from(&s[..])
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in a new issue