Merge branch 'refactor-fileid' into bootstrap-storage-backends

This commit is contained in:
Matthias Beyer 2015-11-23 19:17:31 +01:00
commit 7c96a10488
4 changed files with 26 additions and 20 deletions

View file

@ -9,22 +9,20 @@ use std::vec::Vec;
use glob::glob;
use glob::Paths;
use storage::file::{File, FileID};
use module::Module;
use storage::file::File;
use storage::file_id::*;
type BackendOperationResult = Result<(), StorageBackendError>;
pub struct StorageBackend<'a> {
pub struct StorageBackend {
basepath: String,
module: &'a Module,
}
impl<'a> StorageBackend<'a> {
impl StorageBackend {
fn new(basepath: String, module: &'a Module) -> StorageBackend<'a> {
fn new(basepath: String) -> StorageBackend {
StorageBackend {
basepath: basepath,
module: module,
}
}
@ -35,7 +33,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 +64,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

View file

@ -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,12 +163,10 @@ pub fn match_header_spec<'a>(spec: &'a FileHeaderSpec, data: &'a FileHeaderData)
None
}
pub type FileID = String;
pub struct File {
header : FileHeaderData,
data : String,
id : String
id : FileID,
}
impl<'a> File {
@ -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
View 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())
}

View file

@ -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;