pub struct FileMatcher { /* 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 FileMatcher
impl FileMatcher
Sourcepub fn find_files(&self, path: &Path) -> Option<&FilesParagraph>
pub fn find_files(&self, path: &Path) -> Option<&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<(&FilesParagraph, &GlobPattern)>
pub fn find_match(&self, path: &Path) -> Option<(&FilesParagraph, &GlobPattern)>
Find the files paragraph that matches the given path, along with the pattern that claimed it.
§Examples
use debian_copyright::lossless::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 !RefUnwindSafe for FileMatcher
impl !Send for FileMatcher
impl !Sync for FileMatcher
impl !UnwindSafe for FileMatcher
impl Freeze for FileMatcher
impl Unpin for FileMatcher
impl UnsafeUnpin for FileMatcher
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