pub struct Analysis<T> {
pub value: T,
pub status: Status,
pub coverage: Coverage,
pub warnings: Vec<Diagnostic>,
pub assumptions: Vec<Assumption>,
pub provenance: Provenance,
}Expand description
A value, and everything needed to judge it.
Dereferences to the value, so reading the answer costs one character and reading the rest is there when it matters. Ergonomics are load-bearing here: a contract that makes ordinary work painful gets bypassed, and a bypassed contract records nothing.
§Examples
use molframe_core::contract::{Analysis, AnalysisPolicy, Coverage, Status};
let policy = AnalysisPolicy::default();
let radius = Analysis::complete(14.2_f64, Coverage::complete(1_960), &policy);
assert_eq!(*radius, 14.2);
assert_eq!(radius.status, Status::Complete);
assert_eq!(radius.coverage.fraction(), 1.0);Fields§
§value: TThe answer.
status: StatusHow far the analysis got.
coverage: CoverageHow much of the intended data was used.
warnings: Vec<Diagnostic>What the analysis found worth saying.
assumptions: Vec<Assumption>What it decided on the caller’s behalf.
provenance: ProvenanceWhere the inputs came from and under what policy.
Implementations§
Source§impl<T> Analysis<T>
impl<T> Analysis<T>
Sourcepub fn complete(value: T, coverage: Coverage, policy: &AnalysisPolicy) -> Self
pub fn complete(value: T, coverage: Coverage, policy: &AnalysisPolicy) -> Self
A complete result.
Sourcepub fn partial(value: T, coverage: Coverage, policy: &AnalysisPolicy) -> Self
pub fn partial(value: T, coverage: Coverage, policy: &AnalysisPolicy) -> Self
A result computed over less than it intended.
Sourcepub fn indeterminate(
value: T,
coverage: Coverage,
policy: &AnalysisPolicy,
) -> Self
pub fn indeterminate( value: T, coverage: Coverage, policy: &AnalysisPolicy, ) -> Self
A refusal to answer.
The value is whatever stands in for “nothing”; the status is the result.
Sourcepub fn with_warning(self, warning: Diagnostic) -> Self
pub fn with_warning(self, warning: Diagnostic) -> Self
Attaches a finding.
Sourcepub fn with_assumption(self, assumption: Assumption) -> Self
pub fn with_assumption(self, assumption: Assumption) -> Self
Records a decision made on the caller’s behalf.
Sourcepub fn policy_fingerprint(&self) -> Fingerprint
pub fn policy_fingerprint(&self) -> Fingerprint
The fingerprint of the policy this was computed under.
Sourcepub fn silent_assumptions(&self) -> impl Iterator<Item = &Assumption>
pub fn silent_assumptions(&self) -> impl Iterator<Item = &Assumption>
The decisions the caller never made that could have changed the answer.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Analysis<T>where
T: Freeze,
impl<T> RefUnwindSafe for Analysis<T>where
T: RefUnwindSafe,
impl<T> Send for Analysis<T>where
T: Send,
impl<T> Sync for Analysis<T>where
T: Sync,
impl<T> Unpin for Analysis<T>where
T: Unpin,
impl<T> UnsafeUnpin for Analysis<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Analysis<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more