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 Forget for WorkspaceMatcher
impl Freeze for WorkspaceMatcherwhere
*const u8 is !null: Freeze,
PhantomData<(OsString, ())>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<GlobSetMatchStrategy>: Freeze,
PhantomData<PathBuf>: Freeze,
PhantomData<SourcePattern>: Freeze,
*const ArcInner<GitIgnores> is !null: Freeze,
PhantomData<ArcInner<GitIgnores>>: Freeze,
impl Move for WorkspaceMatcher
impl RefUnwindSafe for WorkspaceMatcherwhere
Atomic<usize>: RefUnwindSafe,
Pool<Cache, Box<dyn Fn() -> Cache + Sync + Send + UnwindSafe + RefUnwindSafe>>: RefUnwindSafe,
Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + Send + UnwindSafe + RefUnwindSafe>>: RefUnwindSafe,
Pool<Vec<usize>, fn() -> Vec<usize>>: RefUnwindSafe,
impl Send for WorkspaceMatcherwhere
RawTable<(OsString, ())>: Send,
RawVecInner: Send,
RawTable<(Vec<u8>, Vec<usize>)>: Send,
Arc<dyn AcAutomaton>: Send,
RawTable<(Vec<u8>, Vec<(usize, Regex)>)>: Send,
Arc<RegexI>: Send,
BoxRaw<Pool<Cache, Box<dyn Fn() -> Cache + Sync + Send + UnwindSafe + RefUnwindSafe>>>: Send,
Arc<Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + Send + UnwindSafe + RefUnwindSafe>>>: Send,
Arc<GitIgnores>: Send,
impl Sync for WorkspaceMatcherwhere
RawTable<(OsString, ())>: Sync,
RawVecInner: Sync,
RawTable<(Vec<u8>, Vec<usize>)>: Sync,
Arc<dyn AcAutomaton>: Sync,
RawTable<(Vec<u8>, Vec<(usize, Regex)>)>: Sync,
Arc<RegexI>: Sync,
BoxRaw<Pool<Cache, Box<dyn Fn() -> Cache + Sync + Send + UnwindSafe + RefUnwindSafe>>>: Sync,
Arc<Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + Send + UnwindSafe + RefUnwindSafe>>>: Sync,
Arc<GitIgnores>: Sync,
impl Unpin for WorkspaceMatcherwhere
*const u8 is !null: Unpin,
Arc<dyn AcAutomaton>: Unpin,
Arc<RegexI>: Unpin,
Box<Pool<Cache, Box<dyn Fn() -> Cache + Sync + Send + UnwindSafe + RefUnwindSafe>>>: Unpin,
Arc<Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + Send + UnwindSafe + RefUnwindSafe>>>: Unpin,
Arc<GitIgnores>: Unpin,
impl UnsafeUnpin for WorkspaceMatcherwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(OsString, ())>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<GlobSetMatchStrategy>: UnsafeUnpin,
PhantomData<PathBuf>: UnsafeUnpin,
PhantomData<SourcePattern>: UnsafeUnpin,
*const ArcInner<GitIgnores> is !null: UnsafeUnpin,
PhantomData<ArcInner<GitIgnores>>: UnsafeUnpin,
impl UnwindSafe for WorkspaceMatcherwhere
NonNull<u8>: UnwindSafe,
RawVecInner: UnwindSafe,
HashMap<Vec<u8>, Vec<usize>, BuildHasherDefault<Hasher>>: UnwindSafe,
Arc<dyn AcAutomaton>: UnwindSafe,
HashMap<Vec<u8>, Vec<(usize, Regex)>, BuildHasherDefault<Hasher>>: UnwindSafe,
Arc<RegexI>: UnwindSafe,
BoxRaw<Pool<Cache, Box<dyn Fn() -> Cache + Sync + Send + UnwindSafe + RefUnwindSafe>>>: UnwindSafe,
Arc<Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + Send + UnwindSafe + RefUnwindSafe>>>: UnwindSafe,
Arc<GitIgnores>: UnwindSafe,
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