aboutsummaryrefslogtreecommitdiffstats
path: root/src/search.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-11-30 03:11:38 -0600
committerToby Vincent <tobyv13@gmail.com>2022-11-30 03:11:38 -0600
commit47fe04dfb634eba3c24403013cf92960237cf761 (patch)
treec3fc4e3f8a480af8fb9020e000cdc391c840eaa2 /src/search.rs
parentfa956cc1598f69c81d6db54b4e2e8f5f35cd9b23 (diff)
revert: remove figment from the lib (moved to bin)
Diffstat (limited to 'src/search.rs')
-rw-r--r--src/search.rs40
1 files changed, 10 insertions, 30 deletions
diff --git a/src/search.rs b/src/search.rs
index 6249da4..fc794ea 100644
--- a/src/search.rs
+++ b/src/search.rs
@@ -1,14 +1,13 @@
-use figment::Provider;
-use std::vec::IntoIter;
-
-use self::entry::EntryIter;
-use crate::{config::Entry, project::ProjectItem, Config, Result};
+use self::entry::SearchEntry;
+use crate::{config::SearchEntryConfig, project::ProjectItem};
pub mod entry;
+type EntryIter = std::vec::IntoIter<SearchEntryConfig>;
+
pub struct Search {
- iter: IntoIter<Entry>,
- curr: Option<EntryIter>,
+ iter: EntryIter,
+ curr: Option<SearchEntry>,
}
impl std::fmt::Debug for Search {
@@ -19,28 +18,9 @@ impl std::fmt::Debug for Search {
}
}
-impl Search {
- pub fn new() -> Result<Self> {
- Self::from_provider(Config::figment())
- }
-
- /// Extract `Config` from `provider` to construct new `Paths`
- pub fn from_provider<T: Provider>(provider: T) -> Result<Self> {
- Config::extract(&provider)
- .map_err(Into::into)
- .map(|config| config.paths.into())
- }
-}
-
-impl From<Config> for Search {
- fn from(config: Config) -> Self {
- config.paths.into()
- }
-}
-
impl<T> From<T> for Search
where
- T: IntoIterator<IntoIter = IntoIter<Entry>>,
+ T: IntoIterator<IntoIter = EntryIter>,
{
fn from(value: T) -> Self {
Self {
@@ -86,17 +66,17 @@ mod tests {
let project4 = temp_dir.join("subdir/project4");
let paths = Search::from(Vec::from([
- Entry {
+ SearchEntryConfig {
path_buf: project_dir.to_owned(),
max_depth: Some(1),
..Default::default()
},
- Entry {
+ SearchEntryConfig {
path_buf: project3.to_owned(),
max_depth: Some(0),
..Default::default()
},
- Entry {
+ SearchEntryConfig {
path_buf: project4.to_owned(),
max_depth: Some(0),
..Default::default()