pub struct Analysis<T> {
pub coverage: Coverage,
pub warnings: Vec<Diagnostic>,
pub assumptions: Vec<Assumption>,
pub provenance: Provenance,
/* private fields */
}Expand description
An outcome, and everything needed to judge it.
The answer is behind Analysis::outcome, Analysis::value or
Analysis::into_result, each of which says what happens when there is no
answer. There is no Deref to the value: a contract that lets the value be
read without asking whether it exists is a contract the indeterminate case
can slip through.
§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.value(), Some(&14.2));
assert_eq!(radius.status(), Status::Complete);
assert_eq!(radius.coverage.fraction(), 1.0);Fields§
§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 determinate(
value: T,
quality: Quality,
coverage: Coverage,
policy: &AnalysisPolicy,
) -> Self
pub fn determinate( value: T, quality: Quality, coverage: Coverage, policy: &AnalysisPolicy, ) -> Self
An answer of the given quality.
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 ambiguous(value: T, coverage: Coverage, policy: &AnalysisPolicy) -> Self
pub fn ambiguous(value: T, coverage: Coverage, policy: &AnalysisPolicy) -> Self
A result that is one of several defensible ones.
Sourcepub fn indeterminate(
reason: Indeterminacy,
coverage: Coverage,
policy: &AnalysisPolicy,
) -> Self
pub fn indeterminate( reason: Indeterminacy, coverage: Coverage, policy: &AnalysisPolicy, ) -> Self
A refusal to answer, with the reason.
There is no value to supply and none to read back.
Sourcepub const fn from_parts(
outcome: Outcome<T>,
quality: Quality,
coverage: Coverage,
warnings: Vec<Diagnostic>,
assumptions: Vec<Assumption>,
provenance: Provenance,
) -> Self
pub const fn from_parts( outcome: Outcome<T>, quality: Quality, coverage: Coverage, warnings: Vec<Diagnostic>, assumptions: Vec<Assumption>, provenance: Provenance, ) -> Self
Assembles an analysis from its parts.
quality qualifies a determinate outcome and is ignored for an
indeterminate one, which has no answer to qualify.
Sourcepub fn with_atom_origin(self, origin: Vec<u32>) -> Self
pub fn with_atom_origin(self, origin: Vec<u32>) -> Self
Records which input atom each analysed atom is.
A governed analysis runs over a system the policy builds: the input with some atoms dropped (a conformer not chosen, hydrogens excluded) or copied (an assembly). The atom indices in its result number that system, not the input; this map says which input atom each one is, and copies of an atom share it.
Sourcepub fn atom_origin(&self) -> Option<&[u32]>
pub fn atom_origin(&self) -> Option<&[u32]>
For each analysed atom, the input atom it is; None when the result’s atoms are the
input’s own.
Sourcepub fn into_parts(
self,
) -> (Outcome<T>, Quality, Coverage, Vec<Diagnostic>, Vec<Assumption>, Provenance)
pub fn into_parts( self, ) -> (Outcome<T>, Quality, Coverage, Vec<Diagnostic>, Vec<Assumption>, Provenance)
Takes the analysis apart, for code that builds a new one from an old one.
Sourcepub fn into_outcome(self) -> Outcome<T>
pub fn into_outcome(self) -> Outcome<T>
Consumes the analysis, keeping only the outcome.
Sourcepub const fn indeterminacy(&self) -> Option<&Indeterminacy>
pub const fn indeterminacy(&self) -> Option<&Indeterminacy>
The reason there is no answer, if there is none.
Sourcepub fn into_result(self) -> Result<T, Indeterminacy>
pub fn into_result(self) -> Result<T, Indeterminacy>
Consumes the analysis: the answer, or the reason it is missing.
§Errors
Returns the Indeterminacy when no defensible answer exists.
Sourcepub const fn status(&self) -> Status
pub const fn status(&self) -> Status
How far the analysis got: the quality of its answer, or Indeterminate.
Sourcepub fn degrade(&mut self, quality: Quality)
pub fn degrade(&mut self, quality: Quality)
Lowers the quality to quality if that is worse; no effect on a refusal.
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,
threshold: f64,
) -> impl Iterator<Item = &Assumption>
pub fn silent_assumptions( &self, threshold: f64, ) -> impl Iterator<Item = &Assumption>
The decisions the caller never made that measurably changed the answer by
at least threshold.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Analysis<T>
impl<T> RefUnwindSafe for Analysis<T>where
Outcome<T>: RefUnwindSafe,
impl<T> Send for Analysis<T>
impl<T> Sync for Analysis<T>
impl<T> Unpin for Analysis<T>
impl<T> UnsafeUnpin for Analysis<T>where
Outcome<T>: UnsafeUnpin,
impl<T> UnwindSafe for Analysis<T>where
Outcome<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