Add StorageBackend builder

This commit is contained in:
Matthias Beyer 2015-11-23 19:54:08 +01:00
parent e1faad7a28
commit da792694c5

View file

@ -14,6 +14,9 @@ use glob::Paths;
use storage::file::File;
use storage::file_id::*;
use module::Module;
use runtime::Runtime;
pub type BackendOperationResult = Result<(), StorageBackendError>;
pub struct StorageBackend {
@ -22,12 +25,17 @@ pub struct StorageBackend {
impl StorageBackend {
fn new(basepath: String) -> StorageBackend {
pub fn new(basepath: String) -> StorageBackend {
StorageBackend {
basepath: basepath,
}
}
fn build<M: Module>(rt: &Runtime, m: &M) -> StorageBackend {
let path = rt.get_rtp() + m.name() + "/store";
StorageBackend::new(path)
}
fn get_file_ids(&self) -> Option<Vec<FileID>> {
let list = glob(&self.basepath[..]);