Skip to main content

Provenance

Struct Provenance 

Source
pub struct Provenance {
    pub molframe_version: &'static str,
    pub input_source: SourceRef,
    pub input_fingerprint: Option<Fingerprint>,
    pub policy: AnalysisPolicy,
    pub policy_fingerprint: Fingerprint,
    pub profile: Option<ProfileId>,
    pub algorithm: Option<AlgorithmId>,
    pub parameters: AnalysisParameters,
    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 str

The version of molframe that produced the result.

§input_source: SourceRef

Where the input came from.

§input_fingerprint: Option<Fingerprint>

A fingerprint of the input’s bytes, where they were read.

§policy: AnalysisPolicy

The policy in force.

§policy_fingerprint: Fingerprint

A 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: AnalysisParameters

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

Source

pub fn new(policy: &AnalysisPolicy) -> Self

Starts a record under policy.

Source

pub fn with_source(self, source: SourceRef) -> Self

Records where the input came from.

Source

pub const fn with_input_fingerprint(self, fingerprint: Fingerprint) -> Self

Records a fingerprint of the input’s bytes.

Source

pub fn with_timestamp(self, timestamp: impl Into<Box<str>>) -> Self

Records when the analysis ran.

Source

pub fn with_algorithm(self, algorithm: AlgorithmId) -> Self

Records the versioned algorithm used by this analysis.

Source

pub fn with_parameter( self, name: impl Into<Box<str>>, value: ParameterValue, ) -> Self

Records or replaces one result-affecting parameter.

Source

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

Source

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.

Source

pub fn to_mmcif(&self) -> String

Serialises the complete record as a standalone mmCIF data block.

The two-column category is deliberately lossless and extensible: older readers can preserve fields they do not interpret.

Trait Implementations§

Source§

impl Clone for Provenance

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Provenance

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, !>

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.