pub struct WorkspaceMatcher { /* private fields */ }Expand description
Resolves whether a single path belongs to the workspace database and, if so,
as which FileType. Built once from a DatabaseConfiguration; cheap to
query per path.
Implementations§
Source§impl WorkspaceMatcher
impl WorkspaceMatcher
Sourcepub fn from_configuration(
configuration: &DatabaseConfiguration<'_>,
) -> Result<Self, DatabaseError>
pub fn from_configuration( configuration: &DatabaseConfiguration<'_>, ) -> Result<Self, DatabaseError>
Builds a matcher from a database configuration.
§Errors
Returns a DatabaseError if a source or exclude glob fails to compile.
Sourcepub fn with_git_ignores(self, ignores: Arc<GitIgnores>) -> Self
pub fn with_git_ignores(self, ignores: Arc<GitIgnores>) -> Self
Classify source files that Git ignores as vendored, as the loader does.
Sourcepub fn classify(&self, file: &Path) -> Option<FileType>
pub fn classify(&self, file: &Path) -> Option<FileType>
Returns the FileType for file if it would be part of the database,
or None if the path lies outside every configured root or is excluded.
Sourcepub fn source_path<'path>(
&self,
requested: &'path Path,
resolved: &'path Path,
) -> &'path Path
pub fn source_path<'path>( &self, requested: &'path Path, resolved: &'path Path, ) -> &'path Path
The path a file opened as requested is kept under: the requested path below a
source root, which keeps the loader’s symlinked directories, or else resolved.
Sourcepub fn exclusions(
&self,
exclusions: &[Exclusion<'_>],
glob: GlobSettings,
) -> Result<PathExclusions, DatabaseError>
pub fn exclusions( &self, exclusions: &[Exclusion<'_>], glob: GlobSettings, ) -> Result<PathExclusions, DatabaseError>
exclusions on top of these sources, matched the way the loader applies a
command’s excludes while it walks them.
§Errors
Returns a DatabaseError if a glob fails to compile.
Sourcepub fn contains(&self, path: &Path) -> bool
pub fn contains(&self, path: &Path) -> bool
Returns true if path would be part of the database.
Sourcepub fn watch_roots(&self) -> impl Iterator<Item = &Path>
pub fn watch_roots(&self) -> impl Iterator<Item = &Path>
Roots for filesystem watchers. The loader walks a root unless a path exclusion covers it.
Sourcepub fn can_contain_files(&self, directory: &Path) -> bool
pub fn can_contain_files(&self, directory: &Path) -> bool
Whether a directory can contain files from any configured source, as the loader walks them.
Sourcepub fn extensions(&self) -> impl Iterator<Item = &OsStr>
pub fn extensions(&self) -> impl Iterator<Item = &OsStr>
File extensions accepted below the configured roots.
Sourcepub fn is_excluded(&self, canonical: &Path) -> bool
pub fn is_excluded(&self, canonical: &Path) -> bool
Check an absolute source path against the configured exclusions.
Sourcepub fn excludes_directory(&self, directory: &Path) -> bool
pub fn excludes_directory(&self, directory: &Path) -> bool
Whether a path exclusion covers directory. File globs never exclude a
directory: the loader still walks one that a glob names.
Trait Implementations§
Source§impl Clone for WorkspaceMatcher
impl Clone for WorkspaceMatcher
Auto Trait Implementations§
impl Freeze for WorkspaceMatcher
impl RefUnwindSafe for WorkspaceMatcher
impl Send for WorkspaceMatcher
impl Sync for WorkspaceMatcher
impl Unpin for WorkspaceMatcher
impl UnsafeUnpin for WorkspaceMatcher
impl UnwindSafe for WorkspaceMatcher
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more