Skip to main content

Crate phasesmith_model

Crate phasesmith_model 

Source
Expand description

Application-neutral owned records shared by scripting and native hosts.

These types describe validated live domain state. Persistence wire records, migrations, PyO3 objects, and Tauri command payloads deliberately live in adapter crates instead of being derived directly from this model. Applications normally use this crate through phasesmith::model.

§Core records

  • PatternRecord owns a strictly increasing grid and aligned observations, uncertainties, mask, and fixed background.
  • TofPatternRecord owns the corresponding explicitly microsecond-domain time-of-flight record; the coordinate types cannot be interchanged.
  • StructuralPhaseRecord owns one crystal-structure phase and its provider requirements.
  • HistogramRecord combines observed data, an experiment, and referenced phase IDs.
  • ProjectRecord is a revisioned multi-histogram project snapshot.
  • RecordId is the validated stable identifier shared across records.

§Example

use phasesmith_model::PatternRecord;

let pattern = PatternRecord::new(
    vec![20.0, 20.1],
    Some(vec![100.0, 120.0]),
    Some(vec![2.0, 2.5]),
    None,
    None,
)?;
assert_eq!(pattern.sample_count(), 2);
assert_eq!(pattern.background_y, [0.0, 0.0]);

Constructors validate records at trust boundaries. Public fields remain available for efficient adapter construction, so call validate again after direct mutation or before crossing into persistence/workflow code.

Structs§

CapabilityDiagnostic
One host-capability diagnostic tied to a stable phase.
ExperimentRecord
Constant-wavelength experiment shared by native workflows and adapters.
FixedWavelengthSpectrum
Validated fixed radiation components in input order.
HistogramRecord
One independently observed dataset in a multi-histogram project.
HostCapabilities
Provider versions available to one application host.
PatternRecord
Owned observed powder pattern for one histogram.
ProjectRecord
Revisioned application-neutral project snapshot.
ProviderRequirement
Exact external provider capability required by a phase.
RecordId
Stable project-owned identifier used for projects, histograms, and phases.
StructuralPhaseRecord
One validated structural phase and its optional extension requirements.
TofExperimentRecord
One explicitly microsecond-domain time-of-flight experiment.
TofHistogramRecord
One independently observed TOF dataset in a multi-histogram project.
TofPatternRecord
Owned time-of-flight powder pattern with an explicitly microsecond coordinate axis.

Enums§

CapabilityReason
Stable reason a project capability is unavailable to a host.
DomainError
Invalid native domain or project data.
RadiationDefinition
Radiation attached to one constant-wavelength histogram.
RadiationProbe
X-ray or neutron radiation selection.