pub enum FilterViolation {
NotConformed,
Failed(Error),
}Expand description
The outcome of re-checking a filter against a value a relationship’s method derived, rather than a value written externally.
See crate::sheet::Sheet::filter_violation.
§Examples
use adam_rs::{Filter, FilterViolation, Method, Sheet};
let mut sheet = Sheet::new();
let input = sheet.add_source(20_i32);
let output = sheet.add_cell(0_i32);
sheet.add_filter(output, Filter::from_fn_0(|v: &i32| Ok((*v).min(10))))?;
sheet.add_relationship(vec![Method::from_fn_1_1(input, output, |v: &i32| Ok(*v))])?;
sheet.propagate()?;
assert!(matches!(sheet.filter_violation(output), Some(FilterViolation::NotConformed)));
assert_eq!(*sheet.read::<i32>(output)?, 20);Variants§
NotConformed
The filter succeeded but its output differs from the cell’s current value. Only
ever recorded for a derived cell (Sheet::propagate’s post-execution
diagnostic phase) — a filtered source cell’s filter output is unconditionally
authoritative once computed (see PlanStep::FilterReclamp), so this variant
never applies there.
Failed(Error)
The filter’s function itself returned an error, or returned a value of a
different type than the cell — both treated as an equally soft diagnostic (see
the design spec §4 for why a filter’s own Err is not a propagation-aborting
failure the way a Requirement’s is). Can occur on either side: a derived
cell’s read-only diagnostic check, or a source cell’s live reclamp, in which
case the cell’s stored value is left unchanged.