Skip to main content

marser_trace_schema/
rule.rs

1//! AI assistance: this file was written with AI assistance. The maintainer reviewed it and did not find errors.
2
3use serde::{Deserialize, Serialize};
4
5/// Call-site metadata for a traced rule (not serialized as a standalone trace value).
6#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
7pub struct RuleSourceMetadata {
8    pub file: &'static str,
9    pub line: u32,
10    pub column: u32,
11    pub rule_name: Option<&'static str>,
12}
13
14impl RuleSourceMetadata {
15    pub const fn new(file: &'static str, line: u32, column: u32) -> Self {
16        Self {
17            file,
18            line,
19            column,
20            rule_name: None,
21        }
22    }
23
24    pub const fn with_rule_name(self, rule_name: &'static str) -> Self {
25        Self {
26            rule_name: Some(rule_name),
27            ..self
28        }
29    }
30}
31
32#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
33pub struct RuleIdentity {
34    pub rule_id: u64,
35    pub rule_name: Option<String>,
36    pub rule_file: String,
37    pub rule_line: u32,
38    pub rule_column: u32,
39}
40
41#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
42pub struct TraceLocation {
43    pub file: String,
44    pub line: u32,
45    pub column: u32,
46}