pub struct Provenance {
pub molframe_version: &'static str,
pub input_source: SourceRef,
pub input_digest: Option<ContentDigest>,
pub policy: AnalysisPolicy,
pub policy_fingerprint: Fingerprint,
pub profile: Option<ProfileId>,
pub algorithm: Option<AlgorithmId>,
pub parameters: BTreeMap<Box<str>, ParameterValue>,
pub schema_version: Option<DictionaryVersion>,
pub component_version: Option<DictionaryVersion>,
pub timestamp: Option<Box<str>>,
}Expand description
Everything needed to reproduce a result.
§Examples
use molframe_core::contract::{AnalysisPolicy, Provenance, SourceRef};
let policy = AnalysisPolicy::default();
let record = Provenance::new(&policy).with_source(SourceRef::path("1abc.cif"));
assert_eq!(record.profile.map(|profile| profile.as_str()), Some("molframe-default-1.0"));
assert_eq!(record.policy_fingerprint, policy.fingerprint());Fields§
§molframe_version: &'static strThe version of molframe that produced the result.
input_source: SourceRefWhere the input came from.
input_digest: Option<ContentDigest>The SHA-256 digest of the input’s bytes, where they were read.
policy: AnalysisPolicyThe policy in force.
policy_fingerprint: FingerprintA fingerprint of that policy.
profile: Option<ProfileId>The named profile, where the policy is one unaltered.
algorithm: Option<AlgorithmId>Versioned algorithm, when the result is algorithm-specific.
parameters: BTreeMap<Box<str>, ParameterValue>Sorted typed parameters that can change the result.
schema_version: Option<DictionaryVersion>The version of the schema dictionary consulted.
component_version: Option<DictionaryVersion>The version of the chemical component data consulted.
timestamp: Option<Box<str>>When the analysis ran, if the caller asked for it recorded.
Excluded from every fingerprint.
Implementations§
Source§impl Provenance
impl Provenance
Sourcepub fn new(policy: &AnalysisPolicy) -> Provenance
pub fn new(policy: &AnalysisPolicy) -> Provenance
Starts a record under policy.
Sourcepub fn with_policy_reads(self, fields: &[PolicyField]) -> Provenance
pub fn with_policy_reads(self, fields: &[PolicyField]) -> Provenance
Records which policy fields the analysis actually applied.
A field the policy sets but the analysis never reads cannot change its result, so varying it measures nothing. Recording what was read is what lets an audit tell “stable under this decision” from “never saw this decision”.
Sourcepub fn policy_reads(&self) -> Option<Vec<PolicyField>>
pub fn policy_reads(&self) -> Option<Vec<PolicyField>>
The policy fields the analysis applied, when it recorded them.
Sourcepub fn with_estimand(self, estimand: &str) -> Provenance
pub fn with_estimand(self, estimand: &str) -> Provenance
Records the quantity the analysis estimates, in words.
Two analyses under the same name can ask different questions of the same structure; saying which one was asked is part of what a result means.
Sourcepub fn with_source(self, source: SourceRef) -> Provenance
pub fn with_source(self, source: SourceRef) -> Provenance
Records where the input came from.
Sourcepub const fn with_input_digest(self, digest: ContentDigest) -> Provenance
pub const fn with_input_digest(self, digest: ContentDigest) -> Provenance
Records the SHA-256 digest of the input’s bytes.
Sourcepub fn with_timestamp(self, timestamp: impl Into<Box<str>>) -> Provenance
pub fn with_timestamp(self, timestamp: impl Into<Box<str>>) -> Provenance
Records when the analysis ran.
Sourcepub fn with_algorithm(self, algorithm: AlgorithmId) -> Provenance
pub fn with_algorithm(self, algorithm: AlgorithmId) -> Provenance
Records the versioned algorithm used by this analysis.
Sourcepub fn with_parameter(
self,
name: impl Into<Box<str>>,
value: ParameterValue,
) -> Provenance
pub fn with_parameter( self, name: impl Into<Box<str>>, value: ParameterValue, ) -> Provenance
Records or replaces one result-affecting parameter.
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
A fingerprint of everything that affects the result.
Two runs over the same input under the same policy agree here whatever the clock said, which is what makes the value a property of the result rather than of the occasion.
Source§impl Provenance
impl Provenance
Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
Serialises the complete record as deterministic JSON.
Keys follow a fixed order and every policy field is named explicitly. The result is independent of map iteration order.
Trait Implementations§
Source§impl Clone for Provenance
impl Clone for Provenance
Source§fn clone(&self) -> Provenance
fn clone(&self) -> Provenance
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Provenance
impl RefUnwindSafe for Provenance
impl Send for Provenance
impl Sync for Provenance
impl Unpin for Provenance
impl UnsafeUnpin for Provenance
impl UnwindSafe for Provenance
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