pub struct Evidence {
pub label: String,
pub data: EvidenceData,
}Expand description
A piece of structured evidence backing a CheckResult.
Use this to attach decision-grade data (numbers, key-value pairs,
code snippets, file refs) instead of formatting them into the
free-form detail field. Consumers can read the typed payload
directly without parsing text.
§Example
use dev_report::{CheckResult, Evidence};
let check = CheckResult::pass("bench::parse")
.with_evidence(Evidence::numeric("mean_ns", 1234.0))
.with_evidence(Evidence::numeric("baseline_ns", 1100.0));
assert_eq!(check.evidence.len(), 2);Fields§
§label: StringShort human-readable label (e.g. "ops_per_sec").
data: EvidenceDataTyped payload.
Implementations§
Source§impl Evidence
impl Evidence
Sourcepub fn numeric(label: impl Into<String>, value: f64) -> Evidence
pub fn numeric(label: impl Into<String>, value: f64) -> Evidence
Build a numeric-evidence attachment.
§Example
use dev_report::Evidence;
let e = Evidence::numeric("ops_per_sec", 12_500.0);
assert_eq!(e.label, "ops_per_sec");Sourcepub fn numeric_int(label: impl Into<String>, value: i64) -> Evidence
pub fn numeric_int(label: impl Into<String>, value: i64) -> Evidence
Build a numeric-evidence attachment from an integer value.
Preserves precision for counters that exceed f64’s 53-bit
integer range (e.g. iteration counts, byte sizes). The value is
stored as f64 on the wire (the schema is unchanged), but
callers don’t have to perform a possibly-lossy as f64 cast.
For values up to 2^53 the round-trip is exact. Above that,
precision degrades the same way it would for any f64.
§Example
use dev_report::Evidence;
let e = Evidence::numeric_int("iterations", 1_000_000_i64);
assert_eq!(e.label, "iterations");Sourcepub fn kv<I, K, V>(label: impl Into<String>, pairs: I) -> Evidence
pub fn kv<I, K, V>(label: impl Into<String>, pairs: I) -> Evidence
Build a key-value-evidence attachment from any iterable of pairs.
§Example
use dev_report::Evidence;
let e = Evidence::kv("env", [("RUST_LOG", "debug"), ("CI", "true")]);
assert_eq!(e.label, "env");Sourcepub fn snippet(label: impl Into<String>, text: impl Into<String>) -> Evidence
pub fn snippet(label: impl Into<String>, text: impl Into<String>) -> Evidence
Build a snippet-evidence attachment.
§Example
use dev_report::Evidence;
let e = Evidence::snippet("panic", "thread 'main' panicked at ...");
assert_eq!(e.label, "panic");Sourcepub fn file_ref(label: impl Into<String>, path: impl Into<String>) -> Evidence
pub fn file_ref(label: impl Into<String>, path: impl Into<String>) -> Evidence
Build a file-reference-evidence attachment with no line range.
§Example
use dev_report::Evidence;
let e = Evidence::file_ref("source", "src/lib.rs");
assert_eq!(e.label, "source");Sourcepub fn file_ref_lines(
label: impl Into<String>,
path: impl Into<String>,
start: u32,
end: u32,
) -> Evidence
pub fn file_ref_lines( label: impl Into<String>, path: impl Into<String>, start: u32, end: u32, ) -> Evidence
Build a file-reference-evidence attachment with a [start, end]
line range (1-indexed, inclusive).
§Example
use dev_report::Evidence;
let e = Evidence::file_ref_lines("call_site", "src/lib.rs", 42, 47);
assert_eq!(e.label, "call_site");Sourcepub fn kind(&self) -> EvidenceKind
pub fn kind(&self) -> EvidenceKind
Discriminator for the payload variant.
§Example
use dev_report::{Evidence, EvidenceKind};
assert_eq!(Evidence::numeric("x", 1.0).kind(), EvidenceKind::Numeric);