Merge pull request #141 from matthiasbeyer/libimagstore/add-storeid-iter
Libimagstore/add storeid iter
This commit is contained in:
commit
9fbfb9fd37
4 changed files with 32 additions and 1 deletions
|
@ -5,6 +5,7 @@ authors = ["Matthias Beyer <mail@beyermatthias.de>"]
|
|||
|
||||
[dependencies]
|
||||
fs2 = "0.2.2"
|
||||
glob = "0.2.10"
|
||||
regex = "0.1.47"
|
||||
semver = "0.2"
|
||||
toml = "0.1.25"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#[macro_use] extern crate version;
|
||||
extern crate fs2;
|
||||
extern crate glob;
|
||||
extern crate regex;
|
||||
extern crate toml;
|
||||
#[cfg(test)] extern crate tempdir;
|
||||
|
|
|
@ -15,7 +15,7 @@ use regex::Regex;
|
|||
|
||||
use error::{ParserErrorKind, ParserError};
|
||||
use error::{StoreError, StoreErrorKind};
|
||||
use storeid::StoreId;
|
||||
use storeid::{StoreId, StoreIdIterator};
|
||||
use lazyfile::LazyFile;
|
||||
|
||||
/// The Result Type returned by any interaction with the store that could fail
|
||||
|
@ -140,6 +140,11 @@ impl Store {
|
|||
.and_then(|entry| Ok(FileLockEntry::new(self, entry, id)))
|
||||
}
|
||||
|
||||
/// Iterate over all StoreIds for one module name
|
||||
pub fn retrieve_for_module(&self, mod_name: &str) -> StoreIdIterator {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
/// Return the `FileLockEntry` and write to disk
|
||||
pub fn update<'a>(&'a self, entry: FileLockEntry<'a>) -> Result<()> {
|
||||
self._update(&entry)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::path::PathBuf;
|
||||
use glob::Paths;
|
||||
|
||||
/// The Index into the Store
|
||||
pub type StoreId = PathBuf;
|
||||
|
@ -63,6 +64,29 @@ macro_rules! module_entry_path_mod {
|
|||
)
|
||||
}
|
||||
|
||||
pub struct StoreIdIterator {
|
||||
paths: Paths,
|
||||
}
|
||||
|
||||
impl StoreIdIterator {
|
||||
|
||||
pub fn new(paths: Paths) -> StoreIdIterator {
|
||||
StoreIdIterator {
|
||||
paths: paths,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Iterator for StoreIdIterator {
|
||||
type Item = StoreId;
|
||||
|
||||
fn next(&mut self) -> Option<StoreId> {
|
||||
self.paths.next().and_then(|o| o.ok())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
|
|
Loading…
Reference in a new issue