pub trait FileRule: Send + Sync {
type Finding: Serialize + DeserializeOwned + Send;
// Required methods
fn engine_name(&self) -> &str;
fn config_hash(&self) -> String;
fn check_file(&self, path: &Path, root: &Path) -> Vec<Self::Finding>;
fn to_diagnostics(
&self,
findings: Vec<(PathBuf, Vec<Self::Finding>)>,
root: &Path,
files_checked: usize,
) -> DiagnosticsReport;
}Expand description
Trait for native rules that check individual files.
Implementing this trait gives automatic SQLite caching and parallel execution.
Rule authors implement check_file() and to_diagnostics() — the framework handles the rest.
Required Associated Types§
Sourcetype Finding: Serialize + DeserializeOwned + Send
type Finding: Serialize + DeserializeOwned + Send
Serializable per-file finding type.
Required Methods§
Sourcefn engine_name(&self) -> &str
fn engine_name(&self) -> &str
Unique engine name for cache keying (e.g. “long-function”, “high-complexity”).
Sourcefn config_hash(&self) -> String
fn config_hash(&self) -> String
Config hash for cache invalidation (e.g. threshold.to_string()).
Sourcefn check_file(&self, path: &Path, root: &Path) -> Vec<Self::Finding>
fn check_file(&self, path: &Path, root: &Path) -> Vec<Self::Finding>
Check a single file. Returns findings for that file.
path is absolute, root is the project root for computing relative paths.
Sourcefn to_diagnostics(
&self,
findings: Vec<(PathBuf, Vec<Self::Finding>)>,
root: &Path,
files_checked: usize,
) -> DiagnosticsReport
fn to_diagnostics( &self, findings: Vec<(PathBuf, Vec<Self::Finding>)>, root: &Path, files_checked: usize, ) -> DiagnosticsReport
Convert collected findings into a DiagnosticsReport.
findings maps file path to that file’s findings.
files_checked is the total number of files examined (cached + fresh).