2016-01-13 20:47:23 +00:00
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::fs::File;
|
2016-01-12 17:52:03 +00:00
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::result::Result as RResult;
|
2016-01-13 10:53:56 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
use std::sync::RWLock;
|
2016-01-12 17:52:03 +00:00
|
|
|
|
|
|
|
pub use entry::Entry;
|
|
|
|
pub use error::StoreError;
|
|
|
|
|
|
|
|
pub type Result<T> = RResult<T, StoreError>;
|
|
|
|
|
|
|
|
pub struct Store {
|
|
|
|
location: PathBuf,
|
2016-01-13 20:47:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal Path->File cache map
|
|
|
|
*
|
|
|
|
* Caches the files, so they remain flock()ed
|
|
|
|
*
|
|
|
|
* Could be optimized for a threadsafe HashMap
|
|
|
|
*/
|
|
|
|
cache: Arc<RWLock<HashMap<PathBuf, File>>>,
|
2016-01-12 17:52:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Store {
|
|
|
|
|
|
|
|
pub fn create(entry: Entry) -> Result<()> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
2016-01-13 10:53:56 +00:00
|
|
|
pub fn read(path: PathBuf) -> Result<Arc<RWLock<Entry>>> {
|
2016-01-12 17:52:03 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
2016-01-13 10:53:56 +00:00
|
|
|
pub fn update(entry: Arc<RWLock<Entry>>) -> Result<()> {
|
2016-01-12 17:52:03 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn delete(path: PathBuf) -> Result<()> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|