pub struct List<T: Pattern> {
pub patterns: Vec<Mapping<T::Value>>,
pub source: Option<PathBuf>,
pub base: Option<BString>,
}
Expand description
A list of patterns which optionally know where they were loaded from and what their base is.
Knowing their base which is relative to a source directory, it will ignore all path to match against that don’t also start with said base.
Fields§
§patterns: Vec<Mapping<T::Value>>
Patterns and their associated data in the order they were loaded in or specified,
the line number in its source file or its sequence number ((pattern, value, line_number)
).
During matching, this order is reversed.
source: Option<PathBuf>
The path from which the patterns were read, or None
if the patterns
don’t originate in a file on disk.
base: Option<BString>
The parent directory of source, or None
if the patterns are global to match against the repository root.
It’s processed to contain slashes only and to end with a trailing slash, and is relative to the repository root.
Implementations§
source§impl<T> List<T>where
T: Pattern,
impl<T> List<T>where T: Pattern,
Instantiation
sourcepub fn from_bytes(
bytes: &[u8],
source_file: impl Into<PathBuf>,
root: Option<&Path>
) -> Self
pub fn from_bytes( bytes: &[u8], source_file: impl Into<PathBuf>, root: Option<&Path> ) -> Self
source_file
is the location of the bytes
which represents a list of patterns, one pattern per line.
If root
is Some(…)
it’s used to see source_file
as relative to itself, if source_file
is absolute.
If source is relative and should be treated as base, set root
to Some("")
.
sourcepub fn from_file(
source: impl Into<PathBuf>,
root: Option<&Path>,
follow_symlinks: bool,
buf: &mut Vec<u8>
) -> Result<Option<Self>>
pub fn from_file( source: impl Into<PathBuf>, root: Option<&Path>, follow_symlinks: bool, buf: &mut Vec<u8> ) -> Result<Option<Self>>
Create a pattern list from the source
file, which may be located underneath root
, while optionally
following symlinks with follow_symlinks
, providing buf
to temporarily store the data contained in the file.
source§impl<T> List<T>where
T: Pattern,
impl<T> List<T>where T: Pattern,
Utilities
sourcepub fn strip_base_handle_recompute_basename_pos<'a>(
&self,
relative_path: &'a BStr,
basename_pos: Option<usize>,
case: Case
) -> Option<(&'a BStr, Option<usize>)>
pub fn strip_base_handle_recompute_basename_pos<'a>( &self, relative_path: &'a BStr, basename_pos: Option<usize>, case: Case ) -> Option<(&'a BStr, Option<usize>)>
If this list is anchored to a base path, return relative_path
as being relative to our base and return
an updated basename_pos
as well if it was set.
case
is respected for the comparison.
This is useful to turn repository-relative paths into paths relative to a particular search base.
Trait Implementations§
source§impl<T: Ord + Pattern> Ord for List<T>where
T::Value: Ord,
impl<T: Ord + Pattern> Ord for List<T>where T::Value: Ord,
source§impl<T: PartialEq + Pattern> PartialEq<List<T>> for List<T>where
T::Value: PartialEq,
impl<T: PartialEq + Pattern> PartialEq<List<T>> for List<T>where T::Value: PartialEq,
source§impl<T: PartialOrd + Pattern> PartialOrd<List<T>> for List<T>where
T::Value: PartialOrd,
impl<T: PartialOrd + Pattern> PartialOrd<List<T>> for List<T>where T::Value: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more