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.
Trait Implementations§
source§impl Ord for Search
impl Ord for Search
source§impl PartialOrd for Search
impl PartialOrd for Search
impl Eq for Search
impl StructuralPartialEq for Search
Auto Trait Implementations§
impl Freeze for Search
impl RefUnwindSafe for Search
impl Send for Search
impl Sync for Search
impl Unpin for Search
impl UnwindSafe for Search
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)