]> git.proxmox.com Git - pathpatterns.git/commitdiff
MatchEntry: also provide access to other parts
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 20 May 2020 10:37:05 +0000 (12:37 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 20 May 2020 10:37:05 +0000 (12:37 +0200)
In the future we'll probably have a separate Builder type,
but that's an API change.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/match_list.rs

index 0c0eda3a2b3f5cf9d1301b1c276cb22cfbc85e44..ee456dcaa57abd722ae7d8b583938189fed00f10 100644 (file)
@@ -148,18 +148,33 @@ impl MatchEntry {
         self
     }
 
+    #[inline]
+    pub fn match_type(&self) -> MatchType {
+        self.ty
+    }
+
     /// Non-Builder method to change the match type.
     pub fn match_type_mut(&mut self) -> &mut MatchType {
         &mut self.ty
     }
 
+    /// Directly access the pattern.
+    pub fn pattern(&self) -> &MatchPattern {
+        &self.pattern
+    }
+
     /// Non-Builder method to change the pattern.
     pub fn pattern_mut(&mut self) -> &mut MatchPattern {
         &mut self.pattern
     }
 
+    /// Directly access the match flags.
+    pub fn match_flags(&mut self) -> MatchFlag {
+        self.flags
+    }
+
     /// Non-Builder method to change the flags.
-    pub fn flags_mut(&mut self) -> &mut MatchFlag {
+    pub fn match_flags_mut(&mut self) -> &mut MatchFlag {
         &mut self.flags
     }
 
@@ -193,11 +208,6 @@ impl MatchEntry {
         Ok(Self::new(crate::Pattern::new(pattern, pattern_flags)?, ty).flags(flags))
     }
 
-    #[inline]
-    pub fn match_type(&self) -> MatchType {
-        self.ty
-    }
-
     /// Test this entry's file type restrictions against a file mode retrieved from `stat()`.
     pub fn matches_mode(&self, file_mode: u32) -> bool {
         // bitflags' `.contains` means ALL bits must be set, if they are all set we don't