Skip to main content

query_methods_batch

Function query_methods_batch 

Source
pub fn query_methods_batch<'a>(
    queries: &[(&'a str, Option<&'a str>)],
    ra_path: &Path,
) -> Vec<(&'a str, Result<Vec<Method>>)>
Expand description

Queries rust-analyzer for methods on multiple types in parallel.

Spawns one thread per query using std::thread::scope. Each query runs an independent rust-analyzer subprocess, so failures are per-type and do not abort the batch. Results are returned in the same order as queries.

§Example

use rust_meth_lib::analyzer::{find_rust_analyzer, query_methods_batch};

let ra_path = find_rust_analyzer().unwrap();
let queries = &[
    ("Vec<u8>", None),
    ("String", None),
    ("HashMap<String, u32>", None),
];
for (type_name, result) in query_methods_batch(queries, &ra_path) {
    match result {
        Ok(methods) => println!("{type_name}: {} methods", methods.len()),
        Err(e) => eprintln!("{type_name}: {e}"),
    }
}

§Environment Variables

  • RUST_METH_DEBUG - If set, logs raw LSP method lifecycle events to standard error.

§Panics

Panics if any of the spawned background threads for processing queries panics or fails to join (e.g., due to an unhandled thread fault during the LSP session).