summaryrefslogtreecommitdiffstats
path: root/src/projects/entry.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/projects/entry.rs')
-rw-r--r--src/projects/entry.rs76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/projects/entry.rs b/src/projects/entry.rs
deleted file mode 100644
index 739ed83..0000000
--- a/src/projects/entry.rs
+++ /dev/null
@@ -1,76 +0,0 @@
-use ignore::{DirEntry, Walk, WalkBuilder};
-use serde::{Deserialize, Deserializer, Serialize};
-use std::{convert::Infallible, path::PathBuf, str::FromStr};
-
-#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize)]
-#[serde(default)]
-pub struct SearchPath {
- pub path: PathBuf,
- pub hidden: bool,
- pub max_depth: Option<usize>,
-}
-
-impl SearchPath {
- pub fn filter(dir_entry: &DirEntry) -> bool {
- dir_entry.path().join(".git").exists()
- }
-}
-
-impl From<PathBuf> for SearchPath {
- fn from(path: PathBuf) -> Self {
- Self {
- path,
- ..Default::default()
- }
- }
-}
-
-impl From<SearchPath> for Walk {
- fn from(value: SearchPath) -> Self {
- WalkBuilder::new(value.path)
- .standard_filters(true)
- .max_depth(value.max_depth)
- .hidden(!value.hidden)
- .filter_entry(SearchPath::filter)
- .build()
- }
-}
-
-impl FromStr for SearchPath {
- type Err = Infallible;
-
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- s.parse().map(PathBuf::into)
- }
-}
-
-impl<'de> Deserialize<'de> for SearchPath {
- fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
- where
- D: Deserializer<'de>,
- {
- #[derive(Deserialize)]
- #[serde(untagged)]
- enum Variants {
- String(String),
- Struct {
- path: PathBuf,
- hidden: bool,
- recurse: Option<usize>,
- },
- }
-
- match Variants::deserialize(deserializer)? {
- Variants::String(s) => s.parse().map_err(serde::de::Error::custom),
- Variants::Struct {
- path,
- hidden,
- recurse,
- } => Ok(Self {
- path,
- hidden,
- max_depth: recurse,
- }),
- }
- }
-}