pub struct FileMatcher<'a> { /* private fields */ }Expand description
A Copyright’s file patterns, compiled once for looking up many paths.
Built with Copyright::matcher. Unlike Copyright::find_files, which
recompiles every pattern on every call, this compiles each pattern once and
reuses it, and reports which pattern claimed a path.
Implementations§
Source§impl<'a> FileMatcher<'a>
impl<'a> FileMatcher<'a>
Sourcepub fn find_files(&self, path: &Path) -> Option<&'a FilesParagraph>
pub fn find_files(&self, path: &Path) -> Option<&'a FilesParagraph>
Find the files paragraph that matches the given path.
Consistent with the specification, this returns the last paragraph that matches, which is the most specific one.
Sourcepub fn find_match(
&self,
path: &Path,
) -> Option<(&'a FilesParagraph, &GlobPattern)>
pub fn find_match( &self, path: &Path, ) -> Option<(&'a FilesParagraph, &GlobPattern)>
Find the files paragraph that matches the given path, along with the pattern that claimed it.
§Examples
use debian_copyright::Copyright;
use std::path::Path;
let text = "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\n\
\n\
Files: *\n\
License: GPL-3+\n\
Copyright: 2019 John Doe\n\
\n\
Files: debian/*\n\
License: GPL-3+\n\
Copyright: 2019 Jane Packager\n";
let copyright: Copyright = text.parse().unwrap();
let matcher = copyright.matcher().unwrap();
let (_, pattern) = matcher.find_match(Path::new("debian/rules")).unwrap();
assert_eq!(pattern.pattern(), "debian/*");Auto Trait Implementations§
impl<'a> Freeze for FileMatcher<'a>
impl<'a> RefUnwindSafe for FileMatcher<'a>
impl<'a> Send for FileMatcher<'a>
impl<'a> Sync for FileMatcher<'a>
impl<'a> Unpin for FileMatcher<'a>
impl<'a> UnsafeUnpin for FileMatcher<'a>
impl<'a> UnwindSafe for FileMatcher<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more