diff options
Diffstat (limited to 'src/paths/path_entry.rs')
-rw-r--r-- | src/paths/path_entry.rs | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/paths/path_entry.rs b/src/paths/path_entry.rs deleted file mode 100644 index b050009..0000000 --- a/src/paths/path_entry.rs +++ /dev/null @@ -1,59 +0,0 @@ -use serde::{Deserialize, Deserializer, Serialize}; -use std::{convert::Infallible, path::PathBuf, str::FromStr}; - -#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize)] -pub struct PathEntry { - pub path: PathBuf, - pub hidden: bool, - pub recurse: Option<usize>, -} - -impl From<PathBuf> for PathEntry { - fn from(path: PathBuf) -> Self { - Self { - path, - ..Default::default() - } - } -} - -impl FromStr for PathEntry { - type Err = Infallible; - - fn from_str(s: &str) -> Result<Self, Self::Err> { - s.parse().map(PathBuf::into) - } -} - -impl<'de> Deserialize<'de> for PathEntry { - fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> - where - D: Deserializer<'de>, - { - #[derive(Deserialize)] - #[serde(untagged)] - enum Variants { - String(String), - Struct { - path: PathBuf, - #[serde(default)] - hidden: bool, - #[serde(default)] - 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, - recurse, - }), - } - } -} |