pub struct Query {
query: String,
lowercased: String,
path_filter: Vec<String>,
anchor_to_crate: bool,
mode: SearchMode,
assoc_mode: AssocSearchMode,
case_sensitive: bool,
only_types: bool,
libs: bool,
exclude_imports: bool,
}Expand description
A query for searching symbols in the workspace or dependencies.
This struct configures how symbol search is performed, including the search text,
matching strategy, and filtering options. It is used by world_symbols to find
symbols across the codebase.
§Example
let mut query = Query::new("MyStruct".to_string());
query.only_types(); // Only search for type definitions
query.libs(); // Include library dependencies
query.exact(); // Use exact matching instead of fuzzyFields§
§query: StringThe item name to search for (last segment of the path, or full query if no path).
When empty with a non-empty path_filter, returns all items in that module.
lowercased: StringLowercase version of Self::query, pre-computed for efficiency.
Used to build FST automata for case-insensitive index lookups.
path_filter: Vec<String>Path segments to filter by (all segments except the last).
Empty if no :: in the original query.
anchor_to_crate: boolIf true, the first path segment must be a crate name (query started with ::).
mode: SearchModeThe search strategy to use when matching symbols.
- [
SearchMode::Exact]: Symbol name must exactly match the query. - [
SearchMode::Fuzzy]: Symbol name must contain all query characters in order (subsequence match). - [
SearchMode::Prefix]: Symbol name must start with the query string.
Defaults to [SearchMode::Fuzzy].
assoc_mode: AssocSearchModeControls filtering of trait-associated items (methods, constants, types).
AssocSearchMode::Include: Include both associated and non-associated items.AssocSearchMode::Exclude: Exclude trait-associated items from results.AssocSearchMode::AssocItemsOnly: Only return trait-associated items.
Defaults to AssocSearchMode::Include.
case_sensitive: boolWhether the final symbol name comparison should be case-sensitive.
When false, matching is case-insensitive (e.g., “foo” matches “Foo”).
Defaults to false.
only_types: boolWhen true, only return type definitions: structs, enums, unions,
type aliases, built-in types, and traits. Functions, constants, statics,
and modules are excluded.
Defaults to false.
libs: boolWhen true, search library dependency roots instead of local workspace crates.
This enables finding symbols in external dependencies including the standard library.
Defaults to false (search local workspace only).
exclude_imports: boolWhen true, exclude re-exported/imported symbols from results,
showing only the original definitions.
Defaults to false.
Implementations§
Source§impl Query
impl Query
pub fn new(query: String) -> Query
Sourcefn parse_path_query(query: &str) -> (Vec<String>, String, bool)
fn parse_path_query(query: &str) -> (Vec<String>, String, bool)
Parse a query string that may contain path segments.
Returns (path_filter, item_query, anchor_to_crate) where:
path_filter: Path segments to match (all but the last segment)item_query: The item name to search for (last segment)anchor_to_crate: Whether the first segment must be a crate name
Sourcefn is_crate_search(&self) -> bool
fn is_crate_search(&self) -> bool
Returns true if this query is searching for crates (i.e., the query was “::” alone or “::foo” for fuzzy crate search)
pub fn only_types(&mut self)
pub fn libs(&mut self)
pub fn fuzzy(&mut self)
pub fn exact(&mut self)
pub fn prefix(&mut self)
Sourcepub fn assoc_search_mode(&mut self, assoc_mode: AssocSearchMode)
pub fn assoc_search_mode(&mut self, assoc_mode: AssocSearchMode)
Specifies whether we want to include associated items in the result.
pub fn case_sensitive(&mut self)
pub fn exclude_imports(&mut self)
Source§impl Query
impl Query
Sourcepub(crate) fn search<'db, T>(
&self,
indices: &[&'db SymbolIndex<'db>],
cb: impl FnMut(&'db FileSymbol<'db>) -> ControlFlow<T>,
) -> Option<T>
pub(crate) fn search<'db, T>( &self, indices: &[&'db SymbolIndex<'db>], cb: impl FnMut(&'db FileSymbol<'db>) -> ControlFlow<T>, ) -> Option<T>
Search symbols in the given indices.
fn search_maps<'db, T>( &self, indices: &[&'db SymbolIndex<'db>], stream: Union<'_>, cb: impl FnMut(&'db FileSymbol<'db>) -> ControlFlow<T>, ) -> Option<T>
fn matches_assoc_mode(&self, is_trait_assoc_item: bool) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Query
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnwindSafe for Query
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,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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