silens_scan/scan_sort.rs
1//! Ordering choices for scan queries.
2
3/// Ordering applied when a scan query is materialized.
4///
5/// Sorting is intentionally separate from filtering. A query remains
6/// allocation-free while filtering and iterating in source order; calling
7/// [`ScanQuery::sort`](crate::ScanQuery::sort) materializes only borrowed
8/// `(source, finding)` pairs.
9///
10/// Because source ordering is part of this unified enum, sorting requires the
11/// source key type to implement [`Ord`], even when another sort variant is
12/// selected. Equal primary keys use deterministic secondary ordering.
13#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
14#[non_exhaustive]
15pub enum ScanSort {
16 /// Sort by rule identifier in ascending lexical order.
17 RuleId,
18 /// Sort by rule identifier in descending lexical order.
19 RuleIdDescending,
20 /// Sort by source key in ascending order.
21 Source,
22 /// Sort by source key in descending order.
23 SourceDescending,
24 /// Sort by severity in ascending enum order.
25 Severity,
26 /// Sort by severity in descending enum order.
27 SeverityDescending,
28 /// Sort by confidence in ascending enum order.
29 Confidence,
30 /// Sort by confidence in descending enum order.
31 ConfidenceDescending,
32 /// Sort by source location in ascending order.
33 Location,
34 /// Sort by source location in descending order.
35 LocationDescending,
36}