Query

Struct Query 

Source
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 fuzzy

Fields§

§query: String

The 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: String

Lowercase 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: bool

If true, the first path segment must be a crate name (query started with ::).

§mode: SearchMode

The 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: AssocSearchMode

Controls filtering of trait-associated items (methods, constants, types).

Defaults to AssocSearchMode::Include.

§case_sensitive: bool

Whether 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: bool

When 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: bool

When 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: bool

When true, exclude re-exported/imported symbols from results, showing only the original definitions.

Defaults to false.

Implementations§

Source§

impl Query

Source

pub fn new(query: String) -> Query

Source

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

Returns true if this query is searching for crates (i.e., the query was “::” alone or “::foo” for fuzzy crate search)

Source

pub fn only_types(&mut self)

Source

pub fn libs(&mut self)

Source

pub fn fuzzy(&mut self)

Source

pub fn exact(&mut self)

Source

pub fn prefix(&mut self)

Source

pub fn assoc_search_mode(&mut self, assoc_mode: AssocSearchMode)

Specifies whether we want to include associated items in the result.

Source

pub fn case_sensitive(&mut self)

Source

pub fn exclude_imports(&mut self)

Source§

impl Query

Source

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.

Source

fn search_maps<'db, T>( &self, indices: &[&'db SymbolIndex<'db>], stream: Union<'_>, cb: impl FnMut(&'db FileSymbol<'db>) -> ControlFlow<T>, ) -> Option<T>

Source

fn matches_assoc_mode(&self, is_trait_assoc_item: bool) -> bool

Trait Implementations§

Source§

impl Clone for Query

Source§

fn clone(&self) -> Query

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Query

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send + Sync> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Send + Sync>

Convert self into the appropriate boxed form.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

§

fn upcast(self, interner: I) -> U

§

impl<I, T> UpcastFrom<I, T> for T

§

fn upcast_from(from: T, _tcx: I) -> T

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<'a, T> Captures<'a> for T
where T: ?Sized,