Move GlobStoreIdIterator implementation so we can have it non-public
This commit is contained in:
parent
a510e1b6b6
commit
b9d8e5728b
2 changed files with 50 additions and 41 deletions
|
@ -25,7 +25,7 @@ use walkdir::Iter as WalkDirIter;
|
|||
|
||||
use error::{ParserErrorKind, ParserError};
|
||||
use error::{StoreError, StoreErrorKind};
|
||||
use storeid::{IntoStoreId, StoreId, GlobStoreIdIterator, StoreIdIterator};
|
||||
use storeid::{IntoStoreId, StoreId, StoreIdIterator};
|
||||
use lazyfile::LazyFile;
|
||||
|
||||
use hook::aspect::Aspect;
|
||||
|
@ -35,6 +35,8 @@ use hook::accessor::{ MutableHookDataAccessor,
|
|||
use hook::position::HookPosition;
|
||||
use hook::Hook;
|
||||
|
||||
use self::glob_store_iter::*;
|
||||
|
||||
/// The Result Type returned by any interaction with the store that could fail
|
||||
pub type Result<T> = RResult<T, StoreError>;
|
||||
|
||||
|
@ -1253,6 +1255,53 @@ impl Entry {
|
|||
|
||||
}
|
||||
|
||||
mod glob_store_iter {
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::fmt::Error as FmtError;
|
||||
use glob::Paths;
|
||||
use storeid::StoreId;
|
||||
|
||||
pub struct GlobStoreIdIterator {
|
||||
paths: Paths,
|
||||
}
|
||||
|
||||
impl Debug for GlobStoreIdIterator {
|
||||
|
||||
fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> {
|
||||
write!(fmt, "GlobStoreIdIterator")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl GlobStoreIdIterator {
|
||||
|
||||
pub fn new(paths: Paths) -> GlobStoreIdIterator {
|
||||
GlobStoreIdIterator {
|
||||
paths: paths,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Iterator for GlobStoreIdIterator {
|
||||
type Item = StoreId;
|
||||
|
||||
fn next(&mut self) -> Option<StoreId> {
|
||||
self.paths.next().and_then(|o| {
|
||||
match o {
|
||||
Ok(o) => Some(o),
|
||||
Err(e) => {
|
||||
debug!("GlobStoreIdIterator error: {:?}", e);
|
||||
None
|
||||
},
|
||||
}
|
||||
}).map(|p| StoreId::from(p))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
|
|
@ -3,7 +3,6 @@ use std::path::Path;
|
|||
use std::borrow::Borrow;
|
||||
use std::ops::Deref;
|
||||
|
||||
use glob::Paths;
|
||||
use semver::Version;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::fmt::Error as FmtError;
|
||||
|
@ -155,45 +154,6 @@ macro_rules! module_entry_path_mod {
|
|||
)
|
||||
}
|
||||
|
||||
pub struct GlobStoreIdIterator {
|
||||
paths: Paths,
|
||||
}
|
||||
|
||||
impl Debug for GlobStoreIdIterator {
|
||||
|
||||
fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> {
|
||||
write!(fmt, "GlobStoreIdIterator")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl GlobStoreIdIterator {
|
||||
|
||||
pub fn new(paths: Paths) -> GlobStoreIdIterator {
|
||||
GlobStoreIdIterator {
|
||||
paths: paths,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Iterator for GlobStoreIdIterator {
|
||||
type Item = StoreId;
|
||||
|
||||
fn next(&mut self) -> Option<StoreId> {
|
||||
self.paths.next().and_then(|o| {
|
||||
match o {
|
||||
Ok(o) => Some(o),
|
||||
Err(e) => {
|
||||
debug!("GlobStoreIdIterator error: {:?}", e);
|
||||
None
|
||||
},
|
||||
}
|
||||
}).map(|p| StoreId::from(p))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub struct StoreIdIterator {
|
||||
iter: Box<Iterator<Item = StoreId>>,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue