pub struct Search { /* private fields */ }
Expand description
A grouping of lists of patterns while possibly keeping associated to their base path in order to find matches.
Pattern lists with base path are queryable relative to that base, otherwise they are relative to the repository root.
Implementations§
Source§impl Search
impl Search
Instantiation and initialization.
Sourcepub fn new_globals(
files: impl IntoIterator<Item = impl Into<PathBuf>>,
buf: &mut Vec<u8>,
collection: &mut MetadataCollection,
) -> Result<Self>
pub fn new_globals( files: impl IntoIterator<Item = impl Into<PathBuf>>, buf: &mut Vec<u8>, collection: &mut MetadataCollection, ) -> Result<Self>
Create a search instance preloaded with built-ins followed by attribute files
from various global locations.
See Source
for a way to obtain these paths.
Note that parsing is lenient and errors are logged.
buf
is used to readfiles
from disk which will be ignored if they do not exist.collection
will be updated with information necessary to perform lookups later.
Source§impl Search
impl Search
Mutation
Sourcepub fn add_patterns_file(
&mut self,
source: PathBuf,
follow_symlinks: bool,
root: Option<&Path>,
buf: &mut Vec<u8>,
collection: &mut MetadataCollection,
allow_macros: bool,
) -> Result<bool>
pub fn add_patterns_file( &mut self, source: PathBuf, follow_symlinks: bool, root: Option<&Path>, buf: &mut Vec<u8>, collection: &mut MetadataCollection, allow_macros: bool, ) -> Result<bool>
Add the given file at source
to our patterns if it exists, otherwise do nothing.
Update collection
with newly added attribute names.
If a root
is provided, it’s not considered a global file anymore.
If allow_macros
is true
, macros will be processed like normal, otherwise they will be skipped entirely.
Returns true
if the file was added, or false
if it didn’t exist.
Sourcepub fn add_patterns_buffer(
&mut self,
bytes: &[u8],
source: PathBuf,
root: Option<&Path>,
collection: &mut MetadataCollection,
allow_macros: bool,
)
pub fn add_patterns_buffer( &mut self, bytes: &[u8], source: PathBuf, root: Option<&Path>, collection: &mut MetadataCollection, allow_macros: bool, )
Add patterns as parsed from bytes
, providing their source
path and possibly their root
path, the path they
are relative to. This also means that source
is contained within root
if root
is provided.
If allow_macros
is true
, macros will be processed like normal, otherwise they will be skipped entirely.
Sourcepub fn pop_pattern_list(&mut self) -> Option<List<Attributes>>
pub fn pop_pattern_list(&mut self) -> Option<List<Attributes>>
Pop the last attribute patterns list from our queue.
Source§impl Search
impl Search
Access and matching
Sourcepub fn pattern_matching_relative_path(
&self,
relative_path: &BStr,
case: Case,
is_dir: Option<bool>,
out: &mut Outcome,
) -> bool
pub fn pattern_matching_relative_path( &self, relative_path: &BStr, case: Case, is_dir: Option<bool>, out: &mut Outcome, ) -> bool
Match relative_path
, a path relative to the repository, while respective case
-sensitivity and write them to out
Return true
if at least one pattern matched.
Sourcepub fn num_pattern_lists(&self) -> usize
pub fn num_pattern_lists(&self) -> usize
Return the amount of pattern lists contained in this instance.