pub struct EvidenceLink {
pub category: EvidenceCategory,
pub observation: String,
pub reference: String,
pub metric_value: Option<f64>,
pub metric_unit: Option<String>,
pub threshold: Option<f64>,
pub threshold_met: bool,
}Expand description
A single verifiable observation in an EvidenceChain.
Each link records:
- what was observed (
observation) - where it can be verified (
reference) - how much was measured (
metric_value+metric_unit) - whether it cleared the decision threshold (
threshold,threshold_met)
Build links with the fluent API:
use evidence_chain::{EvidenceLink, EvidenceCategory};
let link = EvidenceLink::new(EvidenceCategory::Value, "Score above cutoff", "record:42")
.with_metric(0.87, "probability")
.with_threshold(0.80, true);
assert!(link.threshold_met);
assert_eq!(link.metric_unit.as_deref(), Some("probability"));Fields§
§category: EvidenceCategoryBroad category of this observation.
observation: StringHuman-readable description of the observed fact.
reference: StringVerifiable pointer to the source: an ID, hash, URL, timestamp, etc.
metric_value: Option<f64>Numerical measurement of the observation (optional).
metric_unit: Option<String>Unit of metric_value (e.g. "USD", "blocks", "sat/vB", "ratio").
threshold: Option<f64>Decision threshold for this criterion (optional).
threshold_met: booltrue if metric_value satisfies threshold, or if no threshold applies.
Implementations§
Source§impl EvidenceLink
impl EvidenceLink
Sourcepub fn new(
category: EvidenceCategory,
observation: impl Into<String>,
reference: impl Into<String>,
) -> Self
pub fn new( category: EvidenceCategory, observation: impl Into<String>, reference: impl Into<String>, ) -> Self
Creates a new link with the minimum required fields.
threshold_met defaults to true. Use with_threshold
to set it explicitly when a numeric threshold applies.
Sourcepub fn with_metric(self, value: f64, unit: impl Into<String>) -> Self
pub fn with_metric(self, value: f64, unit: impl Into<String>) -> Self
Attaches a numeric measurement to this link.
Sourcepub fn with_threshold(self, threshold: f64, met: bool) -> Self
pub fn with_threshold(self, threshold: f64, met: bool) -> Self
Records the decision threshold and whether it was met.
Trait Implementations§
Source§impl Clone for EvidenceLink
impl Clone for EvidenceLink
Source§fn clone(&self) -> EvidenceLink
fn clone(&self) -> EvidenceLink
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EvidenceLink
impl Debug for EvidenceLink
Source§impl<'de> Deserialize<'de> for EvidenceLink
impl<'de> Deserialize<'de> for EvidenceLink
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
Auto Trait Implementations§
impl Freeze for EvidenceLink
impl RefUnwindSafe for EvidenceLink
impl Send for EvidenceLink
impl Sync for EvidenceLink
impl Unpin for EvidenceLink
impl UnsafeUnpin for EvidenceLink
impl UnwindSafe for EvidenceLink
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