Outsource file id parsing
This commit is contained in:
parent
b0e5f28528
commit
9aced858ac
4 changed files with 22 additions and 13 deletions
|
@ -9,7 +9,8 @@ use std::vec::Vec;
|
|||
use glob::glob;
|
||||
use glob::Paths;
|
||||
|
||||
use storage::file::{File, FileID};
|
||||
use storage::file::File;
|
||||
use storage::file_id::*;
|
||||
use module::Module;
|
||||
|
||||
type BackendOperationResult = Result<(), StorageBackendError>;
|
||||
|
@ -35,7 +36,7 @@ impl<'a> StorageBackend<'a> {
|
|||
let mut v = vec![];
|
||||
for entry in globlist {
|
||||
if let Ok(path) = entry {
|
||||
v.push(file_id_from_path(path.as_path()));
|
||||
v.push(from_pathbuf(&path));
|
||||
} else {
|
||||
// Entry is not a path
|
||||
}
|
||||
|
@ -66,10 +67,6 @@ impl<'a> StorageBackend<'a> {
|
|||
|
||||
}
|
||||
|
||||
fn file_id_from_path(p: &Path) -> String {
|
||||
String::from("")
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct StorageBackendError {
|
||||
pub action: String, // The file system action in words
|
||||
|
|
|
@ -3,6 +3,7 @@ use std::fmt::{Debug, Display, Formatter};
|
|||
use std::fmt;
|
||||
|
||||
use super::parser::{FileHeaderParser, Parser, ParserError};
|
||||
use storage::file_id::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum FileHeaderSpec {
|
||||
|
@ -162,8 +163,6 @@ pub fn match_header_spec<'a>(spec: &'a FileHeaderSpec, data: &'a FileHeaderData)
|
|||
None
|
||||
}
|
||||
|
||||
pub type FileID = String;
|
||||
|
||||
pub struct File {
|
||||
header : FileHeaderData,
|
||||
data : String,
|
||||
|
@ -180,7 +179,7 @@ impl<'a> File {
|
|||
Ok(File {
|
||||
header: h,
|
||||
data: d,
|
||||
id: File::get_id_from_path(path),
|
||||
id: from_path_string(path),
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -188,10 +187,6 @@ impl<'a> File {
|
|||
self.id.clone()
|
||||
}
|
||||
|
||||
fn get_id_from_path(p: &String) -> FileID {
|
||||
String::from("")
|
||||
}
|
||||
|
||||
fn read_file(p: &String) -> Result<String, ParserError> {
|
||||
Ok(String::from(""))
|
||||
}
|
||||
|
|
16
src/storage/file_id.rs
Normal file
16
src/storage/file_id.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub type FileID = String;
|
||||
|
||||
pub fn from_path_string(s: &String) -> FileID {
|
||||
String::from("")
|
||||
}
|
||||
|
||||
pub fn from_path(p: &Path) -> FileID {
|
||||
String::from("")
|
||||
}
|
||||
|
||||
pub fn from_pathbuf(p: &PathBuf) -> FileID {
|
||||
from_path(p.as_path())
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ pub use std::error::Error;
|
|||
pub use runtime::Runtime;
|
||||
|
||||
pub mod file;
|
||||
pub mod file_id;
|
||||
pub mod parser;
|
||||
pub mod backend;
|
||||
|
||||
|
|
Loading…
Reference in a new issue