Skip to main content

aion/loader/
mod.rs

1//! Workflow package loading surfaces.
2
3use aion_core::PackageVersion;
4use aion_package::ContentHash;
5
6use crate::error::EngineError;
7
8/// Shared, atomically-swappable workflow package catalog.
9pub mod catalog;
10/// Package staging and workflow entry discovery.
11pub mod load;
12/// Durable persistence and startup reload for runtime-deployed packages.
13pub mod persistence;
14/// Serde-ready listing record for loaded workflow versions.
15pub mod version_info;
16
17pub use catalog::{PinnedWorkflow, WorkflowCatalog};
18pub use load::{LoadOutcome, LoadedWorkflow};
19pub use version_info::WorkflowVersionInfo;
20
21/// Canonical durable form of a loaded package version.
22#[must_use]
23pub fn package_version_of(hash: &ContentHash) -> PackageVersion {
24    PackageVersion::new(hash.to_string())
25}
26
27/// Parses a durably recorded package version back to a typed content hash.
28///
29/// # Errors
30///
31/// Returns [`EngineError::Load`] naming the workflow type and the malformed
32/// version text when the recorded value is not a canonical content hash.
33pub fn parse_package_version(
34    workflow_type: &str,
35    version: &PackageVersion,
36) -> Result<ContentHash, EngineError> {
37    version
38        .as_str()
39        .parse::<ContentHash>()
40        .map_err(|error| EngineError::Load {
41            reason: format!(
42                "workflow `{workflow_type}` recorded package version `{version}` that is not a canonical content hash: {error}"
43            ),
44        })
45}