Analyzer::Rust::RustEngine
Inherits FileScanEngine < Analyzer < FileHelper < Reference < Object
Constants
Standard set of HTTP methods that axum::routing::any(...) /
actix web::route() / similar method-agnostic registrations
accept. Mirrors the Go fan_out_verbs set so output formats
see real HTTP methods instead of a non-HTTP "ANY" string.
Class methods
Scan the source for #[cfg(test)] annotations, then capture
the byte range of the following mod/fn/impl block via
simple brace counting. String/char literals are skipped so a
{ inside "foo {" doesn't shift the depth. Rust lifetimes
like 'a look like char literals to a naive quote scanner
and would otherwise drop the close-brace search into oblivion
— see skip_char_or_lifetime.
Shared with all Rust analyzers: axum's extract/path/mod.rs,
salvo's crates/core/src/routing.rs, and similar framework
source files mix production routes with #[cfg(test)] mod tests { ... } blocks. Each analyzer that uses tree-sitter
can call this once per file, then drop any route call whose
ts_node_start_byte falls in one of the returned ranges.
Expand any / all (case-insensitive) into the seven
canonical HTTP methods. Anything else passes through as a
single-element list.
Cargo convention: every .rs immediately under a crate's
tests/ directory is an integration-test binary, never a
production endpoint. The _test.rs / _tests.rs suffix is
equally rigid for unit tests in sibling files. Framework
repos (rocket/Rocket's core/codegen/tests/, actix-web's
actix-web-codegen/tests/, poem's poem-openapi/tests/)
all park hundreds of route registrations under one of these
patterns. Promoted from axum.cr#test_only_path? (#1569) to
the shared engine so the rest of the Rust family benefits.
Takes the scan-base-relative path (Analyzer#base_relative_path),
never the absolute one. Cargo's conventions are relative to the
crate, so matching the absolute path let a directory above the
scan base decide the answer: the same tree cloned into
~/work/tests/myapp reported 0 endpoints instead of 220.