file_matcher/entries/
entry.rs1use std::fmt::Debug;
2
3#[cfg(feature = "serde")]
4use serde::{Serialize, Deserialize};
5
6#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
8#[derive(Debug, Clone, Eq, PartialEq)]
9pub enum EntryName {
10 Exact(String),
11 Any(Vec<String>),
12 AnyNamed(Vec<EntryName>),
13 #[cfg(feature = "regex")]
14 Regex(String),
15 #[cfg(feature = "wildmatch")]
16 Wildmatch(String),
17}
18
19#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
21#[derive(Debug, Clone, Eq, PartialEq)]
22pub enum EntryType {
23 File,
24 Folder,
25 Any,
26}
27
28#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
30#[derive(Debug, Clone)]
31pub(crate) struct EntryNamed {
32 entry_name: EntryName,
33 entry_type: EntryType,
34}
35
36impl EntryNamed {
37 pub fn new(entry_name: EntryName, entry_type: EntryType) -> Self {
38 Self {
39 entry_name,
40 entry_type,
41 }
42 }
43
44 pub fn file(name: EntryName) -> Self {
45 Self::new(name, EntryType::File)
46 }
47
48 pub fn folder(name: EntryName) -> Self {
49 Self::new(name, EntryType::Folder)
50 }
51
52 pub fn any(name: EntryName) -> Self {
53 Self::new(name, EntryType::Any)
54 }
55
56 pub fn entry_name(&self) -> &EntryName {
57 &self.entry_name
58 }
59
60 pub fn entry_type(&self) -> &EntryType {
61 &self.entry_type
62 }
63}