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) -> Self
pub fn numeric(label: impl Into<String>, value: f64) -> Self
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 kv<I, K, V>(label: impl Into<String>, pairs: I) -> Self
pub fn kv<I, K, V>(label: impl Into<String>, pairs: I) -> Self
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>) -> Self
pub fn snippet(label: impl Into<String>, text: impl Into<String>) -> Self
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>) -> Self
pub fn file_ref(label: impl Into<String>, path: impl Into<String>) -> Self
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,
) -> Self
pub fn file_ref_lines( label: impl Into<String>, path: impl Into<String>, start: u32, end: u32, ) -> Self
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);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Evidence
impl<'de> Deserialize<'de> for Evidence
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Evidence
Auto Trait Implementations§
impl Freeze for Evidence
impl RefUnwindSafe for Evidence
impl Send for Evidence
impl Sync for Evidence
impl Unpin for Evidence
impl UnsafeUnpin for Evidence
impl UnwindSafe for Evidence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more