pub struct EvidenceChain {
pub rule_id: String,
pub rule_version: String,
pub links: Vec<EvidenceLink>,
pub strength: EvidenceStrength,
}Expand description
An ordered chain of evidence links for a single decision.
Build the chain by adding EvidenceLinks, then call finalize
to compute the aggregate EvidenceStrength.
rule_id and rule_version identify the rule or model that
produced this chain — use any stable identifiers meaningful to your domain.
§Example
use evidence_chain::{EvidenceChain, EvidenceLink, EvidenceCategory};
let mut chain = EvidenceChain::new("velocity-check", "1.2.0");
chain.add_link(
EvidenceLink::new(EvidenceCategory::Value, "5 transactions in 10 minutes", "window:abc")
.with_metric(5.0, "tx/10min")
.with_threshold(3.0, true),
);
chain.add_link(
EvidenceLink::new(EvidenceCategory::Structural, "All transactions to same recipient", "addr:xyz")
.with_threshold(1.0, true),
);
chain.finalize();
assert_eq!(chain.strength.ratio, 1.0);Fields§
§rule_id: StringIdentifier of the rule or model that produced this chain.
rule_version: StringVersion of the rule or model.
links: Vec<EvidenceLink>Ordered list of evidence observations.
strength: EvidenceStrengthAggregate strength — populated by finalize.
Implementations§
Source§impl EvidenceChain
impl EvidenceChain
Sourcepub fn new(rule_id: impl Into<String>, version: impl Into<String>) -> Self
pub fn new(rule_id: impl Into<String>, version: impl Into<String>) -> Self
Creates an empty chain for the given rule identifier and version.
Sourcepub fn add_link(&mut self, link: EvidenceLink)
pub fn add_link(&mut self, link: EvidenceLink)
Appends an evidence link to the chain.
Sourcepub fn finalize(&mut self)
pub fn finalize(&mut self)
Recomputes EvidenceStrength from the current links.
Idempotent — safe to call multiple times. Call after all links have
been added to get an accurate strength.
Trait Implementations§
Source§impl Clone for EvidenceChain
impl Clone for EvidenceChain
Source§fn clone(&self) -> EvidenceChain
fn clone(&self) -> EvidenceChain
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 EvidenceChain
impl Debug for EvidenceChain
Source§impl<'de> Deserialize<'de> for EvidenceChain
impl<'de> Deserialize<'de> for EvidenceChain
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 EvidenceChain
impl RefUnwindSafe for EvidenceChain
impl Send for EvidenceChain
impl Sync for EvidenceChain
impl Unpin for EvidenceChain
impl UnsafeUnpin for EvidenceChain
impl UnwindSafe for EvidenceChain
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