Skip to main content

InstallationContract

Struct InstallationContract 

Source
pub struct InstallationContract { /* private fields */ }
Expand description

Candidate contract identity pinned by the exact lock.

Implementations§

Source§

impl InstallationContract

Source

pub const fn new( version: ContractVersion, bundle_hash: ContractBundleHash, ) -> InstallationContract

Binds one exact candidate version and bundle.

Source

pub const fn version(self) -> ContractVersion

Exact candidate version.

Examples found in repository?
examples/generate_portability_fixtures.rs (line 181)
93fn generate_domain(root: &Path, domain: &Domain<'_>, write: bool) {
94    let bundle = ContractBundle::decode(
95        &fs::read(
96            root.join(domain.application_root)
97                .join("generated/riffdb.contract.bundle"),
98        )
99        .expect("read adapter contract bundle"),
100    )
101    .expect("decode adapter contract bundle");
102    let adapter = AdapterConformanceManifest::decode_canonical(
103        &fs::read(
104            root.join("fixtures/adapters/conformance")
105                .join(domain.name)
106                .join("adapter.conformance.json"),
107        )
108        .expect("read adapter manifest"),
109    )
110    .expect("decode adapter manifest");
111    let observation_hash = empty_observation_hash(domain.empty_collection);
112    let module_hash = adapter
113        .input()
114        .artifacts
115        .iter()
116        .find(|artifact| artifact.kind() == InstallationArtifactKind::QueryModule)
117        .map(|artifact| QueryModuleHash::from_bytes(*artifact.content_hash().as_bytes()))
118        .expect("adapter query module");
119    let manifest = ApplicationPortabilityManifest::compile(ApplicationPortabilityManifestInput {
120        adapter_manifest_hash: adapter.identity(),
121        contract_lineage: bundle.lineage().clone(),
122        contract_version: bundle.contract_version(),
123        contract_bundle_hash: bundle.bundle_hash(),
124        mappings: domain
125            .mappings
126            .iter()
127            .map(|(entity, command)| {
128                PortableRecordMapping::new(
129                    PortableRecordClass::Entity,
130                    symbol(entity),
131                    PortableReimportStrategy::reimport_command(symbol(command)),
132                )
133            })
134            .collect(),
135        omissions: vec![
136            PortableOmission::new(
137                PortableOmissionClass::Provenance,
138                None,
139                PortableOmissionReason::HistoricalRecordsNotRegenerable,
140            )
141            .expect("provenance omission"),
142            PortableOmission::new(
143                PortableOmissionClass::PublicAudit,
144                None,
145                PortableOmissionReason::HistoricalRecordsNotRegenerable,
146            )
147            .expect("audit omission"),
148        ],
149        observations: vec![
150            ReimportObservation::new_with_parameters(
151                symbol("application_observation"),
152                symbol(domain.query),
153                module_hash,
154                domain
155                    .parameters
156                    .iter()
157                    .map(|(name, suffix)| {
158                        ReimportObservationParameter::new(
159                            symbol(name),
160                            CanonicalValue::Uuid(application_uuid(*suffix)),
161                        )
162                        .expect("observation parameter")
163                    })
164                    .collect(),
165                observation_hash,
166                500,
167            )
168            .expect("observation"),
169        ],
170    })
171    .expect("compile portability manifest");
172    manifest
173        .validate_compiled_contract(&bundle)
174        .expect("compiled contract mapping");
175    assert_eq!(manifest.input().adapter_manifest_hash, adapter.identity());
176    assert_eq!(
177        manifest.input().contract_lineage,
178        adapter.input().contract_lineage
179    );
180    assert!(adapter.input().evolution.iter().any(|evolution| {
181        evolution.successor().version() == manifest.input().contract_version
182            && evolution.successor().bundle_hash() == manifest.input().contract_bundle_hash
183    }));
184    manifest
185        .validate_adapter_conformance(&adapter)
186        .unwrap_or_else(|error| panic!("{} adapter mapping: {error:?}", domain.name));
187
188    let outcome_hash = hash_generated_artifact(format!("{}-outcomes-v1", domain.name).as_bytes());
189    let destination = root.join("fixtures/export").join(domain.name);
190    let receipt = reimport_receipt(&manifest, domain, outcome_hash);
191    update(
192        destination.join("portability-manifest-v3.json"),
193        manifest.canonical_bytes(),
194        write,
195    );
196    let legacy_manifest_path = destination.join("portability-manifest-v2.json");
197    if legacy_manifest_path.is_file() {
198        let legacy_manifest = ApplicationPortabilityManifest::decode_canonical(
199            &fs::read(legacy_manifest_path).expect("read V2 portability manifest"),
200        )
201        .expect("decode V2 portability manifest");
202        let legacy_receipt = reimport_receipt(&legacy_manifest, domain, outcome_hash);
203        update(
204            destination.join("reimport-receipt-v2.json"),
205            legacy_receipt.canonical_bytes(),
206            write,
207        );
208    }
209    update(
210        destination.join("reimport-receipt-v3.json"),
211        receipt.canonical_bytes(),
212        write,
213    );
214}
Source

pub const fn bundle_hash(self) -> ContractBundleHash

Exact candidate bundle hash.

Examples found in repository?
examples/generate_portability_fixtures.rs (line 182)
93fn generate_domain(root: &Path, domain: &Domain<'_>, write: bool) {
94    let bundle = ContractBundle::decode(
95        &fs::read(
96            root.join(domain.application_root)
97                .join("generated/riffdb.contract.bundle"),
98        )
99        .expect("read adapter contract bundle"),
100    )
101    .expect("decode adapter contract bundle");
102    let adapter = AdapterConformanceManifest::decode_canonical(
103        &fs::read(
104            root.join("fixtures/adapters/conformance")
105                .join(domain.name)
106                .join("adapter.conformance.json"),
107        )
108        .expect("read adapter manifest"),
109    )
110    .expect("decode adapter manifest");
111    let observation_hash = empty_observation_hash(domain.empty_collection);
112    let module_hash = adapter
113        .input()
114        .artifacts
115        .iter()
116        .find(|artifact| artifact.kind() == InstallationArtifactKind::QueryModule)
117        .map(|artifact| QueryModuleHash::from_bytes(*artifact.content_hash().as_bytes()))
118        .expect("adapter query module");
119    let manifest = ApplicationPortabilityManifest::compile(ApplicationPortabilityManifestInput {
120        adapter_manifest_hash: adapter.identity(),
121        contract_lineage: bundle.lineage().clone(),
122        contract_version: bundle.contract_version(),
123        contract_bundle_hash: bundle.bundle_hash(),
124        mappings: domain
125            .mappings
126            .iter()
127            .map(|(entity, command)| {
128                PortableRecordMapping::new(
129                    PortableRecordClass::Entity,
130                    symbol(entity),
131                    PortableReimportStrategy::reimport_command(symbol(command)),
132                )
133            })
134            .collect(),
135        omissions: vec![
136            PortableOmission::new(
137                PortableOmissionClass::Provenance,
138                None,
139                PortableOmissionReason::HistoricalRecordsNotRegenerable,
140            )
141            .expect("provenance omission"),
142            PortableOmission::new(
143                PortableOmissionClass::PublicAudit,
144                None,
145                PortableOmissionReason::HistoricalRecordsNotRegenerable,
146            )
147            .expect("audit omission"),
148        ],
149        observations: vec![
150            ReimportObservation::new_with_parameters(
151                symbol("application_observation"),
152                symbol(domain.query),
153                module_hash,
154                domain
155                    .parameters
156                    .iter()
157                    .map(|(name, suffix)| {
158                        ReimportObservationParameter::new(
159                            symbol(name),
160                            CanonicalValue::Uuid(application_uuid(*suffix)),
161                        )
162                        .expect("observation parameter")
163                    })
164                    .collect(),
165                observation_hash,
166                500,
167            )
168            .expect("observation"),
169        ],
170    })
171    .expect("compile portability manifest");
172    manifest
173        .validate_compiled_contract(&bundle)
174        .expect("compiled contract mapping");
175    assert_eq!(manifest.input().adapter_manifest_hash, adapter.identity());
176    assert_eq!(
177        manifest.input().contract_lineage,
178        adapter.input().contract_lineage
179    );
180    assert!(adapter.input().evolution.iter().any(|evolution| {
181        evolution.successor().version() == manifest.input().contract_version
182            && evolution.successor().bundle_hash() == manifest.input().contract_bundle_hash
183    }));
184    manifest
185        .validate_adapter_conformance(&adapter)
186        .unwrap_or_else(|error| panic!("{} adapter mapping: {error:?}", domain.name));
187
188    let outcome_hash = hash_generated_artifact(format!("{}-outcomes-v1", domain.name).as_bytes());
189    let destination = root.join("fixtures/export").join(domain.name);
190    let receipt = reimport_receipt(&manifest, domain, outcome_hash);
191    update(
192        destination.join("portability-manifest-v3.json"),
193        manifest.canonical_bytes(),
194        write,
195    );
196    let legacy_manifest_path = destination.join("portability-manifest-v2.json");
197    if legacy_manifest_path.is_file() {
198        let legacy_manifest = ApplicationPortabilityManifest::decode_canonical(
199            &fs::read(legacy_manifest_path).expect("read V2 portability manifest"),
200        )
201        .expect("decode V2 portability manifest");
202        let legacy_receipt = reimport_receipt(&legacy_manifest, domain, outcome_hash);
203        update(
204            destination.join("reimport-receipt-v2.json"),
205            legacy_receipt.canonical_bytes(),
206            write,
207        );
208    }
209    update(
210        destination.join("reimport-receipt-v3.json"),
211        receipt.canonical_bytes(),
212        write,
213    );
214}

Trait Implementations§

Source§

impl Clone for InstallationContract

Source§

fn clone(&self) -> InstallationContract

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 Copy for InstallationContract

Source§

impl Debug for InstallationContract

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for InstallationContract

Source§

impl Ord for InstallationContract

Source§

fn cmp(&self, other: &InstallationContract) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for InstallationContract

Source§

fn eq(&self, other: &InstallationContract) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for InstallationContract

Source§

fn partial_cmp(&self, other: &InstallationContract) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for InstallationContract

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> Same for T

Source§

type Output = T

Should always be Self
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.