Skip to main content

FindingGraph

Struct FindingGraph 

Source
pub struct FindingGraph { /* private fields */ }
Expand description

Sole owner of findings and their causal edges (todo.md §15.2). Each edge is stored exactly once as a cause → effect pair; the per-finding caused_by/causes views are derived from that one set, so root reduction and cycle checking can never read diverging truths. FindingGraph::into_findings exports findings with both directions filled in, keeping the schema-v2 JSON shape unchanged.

Implementations§

Source§

impl FindingGraph

Source

pub fn new() -> Self

Source

pub fn add_finding(&mut self, finding: Finding) -> Result<(), GraphError>

Adds a finding, rejecting ids already present in the graph. Callers pass findings without edges (detectors never set them; edges are attached via FindingGraph::add_edge).

Source

pub fn add_edge( &mut self, cause: &FindingId, effect: &FindingId, ) -> Result<(), GraphError>

Records that cause caused effect. Rejects unknown ids, duplicate edges, and any edge that would close a cycle (including self-edges).

Source

pub fn roots(&self) -> Vec<&Finding>

Findings with no recorded cause, in insertion order — the same edge set the cycle check validates.

Source

pub fn causes_of(&self, id: &FindingId) -> Vec<&Finding>

Findings that id caused (the cascade direction), derived from the stored edges. Unknown ids yield an empty list.

Source

pub fn caused_by_of(&self, id: &FindingId) -> Vec<&Finding>

Findings that caused id (the root-cause direction), derived from the stored edges. Unknown ids yield an empty list.

Source

pub fn into_findings(self) -> Vec<Finding>

Consumes the graph and returns the findings in insertion order with caused_by/causes filled in from the single stored edge set — the serialized schema-v2 shape is exactly what it was when the fields were set directly.

Trait Implementations§

Source§

impl Debug for FindingGraph

Source§

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

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

impl Default for FindingGraph

Source§

fn default() -> FindingGraph

Returns the “default value” for a type. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.