Skip to main content

Evidence

Struct Evidence 

Source
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: String

Human-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

Source

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());
Source

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");
Source

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));

Trait Implementations§

Source§

impl Clone for Evidence

Source§

fn clone(&self) -> Evidence

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Evidence

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Evidence

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Evidence

Source§

fn eq(&self, other: &Evidence) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Evidence

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Evidence

Source§

impl StructuralPartialEq for Evidence

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,