From 1d69aa5066c6f320d2e2cb9912b7fc4559061467 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 24 Jan 2016 12:16:57 +0100 Subject: [PATCH 1/4] Add dep: glob = 0.2.10 --- libimagstore/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstore/Cargo.toml b/libimagstore/Cargo.toml index 02f99124..e561d15e 100644 --- a/libimagstore/Cargo.toml +++ b/libimagstore/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Matthias Beyer "] [dependencies] fs2 = "0.2.2" +glob = "0.2.10" regex = "0.1.47" semver = "0.2" toml = "0.1.25" From e951666e3d66707d4474c88fdd8280a211b81079 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 24 Jan 2016 12:17:06 +0100 Subject: [PATCH 2/4] Use glob --- libimagstore/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstore/src/lib.rs b/libimagstore/src/lib.rs index b6152caa..a8044b3b 100644 --- a/libimagstore/src/lib.rs +++ b/libimagstore/src/lib.rs @@ -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; From 36770abac5f9814549af80888c6a298db1b4a2d0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 24 Jan 2016 12:17:25 +0100 Subject: [PATCH 3/4] Add iterator type for StoreId --- libimagstore/src/storeid.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libimagstore/src/storeid.rs b/libimagstore/src/storeid.rs index cc826585..b28b13fc 100644 --- a/libimagstore/src/storeid.rs +++ b/libimagstore/src/storeid.rs @@ -1,4 +1,5 @@ use std::path::PathBuf; +use glob::GlobResult; /// The Index into the Store pub type StoreId = PathBuf; @@ -63,6 +64,29 @@ macro_rules! module_entry_path_mod { ) } +struct StoreIdIterator { + globres: GlobResult, +} + +impl StoreIdIterator { + + pub fn new(globres: GlobResult) -> StoreIdIterator { + StoreIdIterator { + globres: globres, + } + } + +} + +impl Iterator for StoreIdIterator { + type Item = StoreId; + + fn next(&mut self) -> Option { + unimplemented!() + } + +} + #[cfg(test)] mod test { From bbd08d9526450c70d9c1e24858793172e54fe596 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 24 Jan 2016 12:17:41 +0100 Subject: [PATCH 4/4] Add Store::retrieve_for_module() --- libimagstore/src/store.rs | 7 ++++++- libimagstore/src/storeid.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index fb222fc5..f38c4643 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -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) diff --git a/libimagstore/src/storeid.rs b/libimagstore/src/storeid.rs index b28b13fc..a8c72b01 100644 --- a/libimagstore/src/storeid.rs +++ b/libimagstore/src/storeid.rs @@ -1,5 +1,5 @@ use std::path::PathBuf; -use glob::GlobResult; +use glob::Paths; /// The Index into the Store pub type StoreId = PathBuf; @@ -64,15 +64,15 @@ macro_rules! module_entry_path_mod { ) } -struct StoreIdIterator { - globres: GlobResult, +pub struct StoreIdIterator { + paths: Paths, } impl StoreIdIterator { - pub fn new(globres: GlobResult) -> StoreIdIterator { + pub fn new(paths: Paths) -> StoreIdIterator { StoreIdIterator { - globres: globres, + paths: paths, } } @@ -82,7 +82,7 @@ impl Iterator for StoreIdIterator { type Item = StoreId; fn next(&mut self) -> Option { - unimplemented!() + self.paths.next().and_then(|o| o.ok()) } }