pub struct Evidence {
pub message: String,
pub pointer: Option<Pointer>,
}Expand description
One observation that supports a diagnosis.
message is the human-readable claim; pointer, when present,
names the source the claim was derived from. Both fields are owned
strings so an Evidence can survive being moved across rule
boundaries without lifetime gymnastics.
Fields§
§message: StringHuman-readable observation. Should be a single sentence;
rendered as a bullet point in the report’s EVIDENCE: block.
pointer: Option<Pointer>Where the observation came from. None is allowed for
statements derived from multiple sources at once (e.g.
“tolerance is 300 s; observed drift 4800 s”) — these are
labelled computed in practice.
Implementations§
Source§impl Evidence
impl Evidence
Sourcepub fn new(message: impl Into<String>) -> Self
pub fn new(message: impl Into<String>) -> Self
Construct an evidence item with no source pointer.
Use this for derived statements that do not refer to a specific case field — for example, summary lines computed by the rule itself (“tolerance is 300 s; observed drift 4800 s”).
§Examples
use api_debug_lab::Evidence;
let e = Evidence::new("Response status 401 Unauthorized");
assert!(e.pointer.is_none());Sourcepub fn with(message: impl Into<String>, source: impl Into<String>) -> Self
pub fn with(message: impl Into<String>, source: impl Into<String>) -> Self
Construct an evidence item that names a logical source but no specific line.
Most rule-emitted evidence uses this form. The source is a
logical path into the case (see Pointer::source).
§Examples
use api_debug_lab::Evidence;
let e = Evidence::with("Authorization header absent", "request.headers.authorization");
assert_eq!(e.pointer.unwrap().source, "request.headers.authorization");Sourcepub fn at_line(
message: impl Into<String>,
source: impl Into<String>,
line: u32,
) -> Self
pub fn at_line( message: impl Into<String>, source: impl Into<String>, line: u32, ) -> Self
Construct an evidence item that points at a specific 1-indexed line of a log file.
This is the form used when a rule has identified a single log
line as the smoking gun. The CLI’s explain subcommand renders
these as [server.log:42] message.
§Examples
use api_debug_lab::Evidence;
let e = Evidence::at_line("timeout entry", "server.log", 3);
assert_eq!(e.pointer.unwrap().line, Some(3));