Skip to main content

harmos_operations/
lib.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12extern crate self as harmos;
13#[cfg(feature = "runtime")]
14mod error;
15pub mod host;
16pub mod lifecycle;
17pub mod storage;
18pub mod streams;
19
20pub mod operations {
21    pub use harmos_domain::operations::*;
22    #[cfg(feature = "lifecycle")]
23    pub use harmos_sdk::operations::Executable;
24}
25
26/* === Re-Exports === */
27
28#[cfg(feature = "runtime")]
29pub use error::Error;
30pub use harmos_domain::*;
31#[cfg(feature = "lifecycle")]
32pub use harmos_sdk::{
33    Context, Dependencies, Dependent, Executable, ExecutionContext, Operation, RegistrationBatch, Resource, ResourceError, Response,
34};
35pub use host::Host;
36pub use lifecycle::Lifecycle;
37pub use storage::Storage;
38pub use streams::Streams;
39
40/* === Imports === */
41
42/* === Constants === */
43
44/* === Macros === */
45
46/* === Type Aliases === */
47
48#[cfg(feature = "runtime")]
49pub type Result<T> = std::result::Result<T, Error>;
50
51/* === Structs === */
52
53pub struct Builtins;
54
55/* === Enums === */
56
57/* === Traits === */
58
59/* === Implementations === */
60
61impl Builtins {
62    pub fn catalog() -> Vec<harmos_domain::OperationDefinition> {
63        let mut definitions = Host::catalog();
64        definitions.extend(Lifecycle::catalog());
65        definitions.extend(Storage::catalog());
66        definitions.extend(Streams::catalog());
67        definitions.push(lifecycle::Initialize::definition());
68        definitions.push(lifecycle::Shutdown::definition());
69        definitions
70    }
71    #[cfg(feature = "runtime")]
72    pub fn registration(dependencies: Dependencies) -> RegistrationBatch {
73        let mut batch = Host::registration(dependencies.clone());
74        batch.operations.extend(Lifecycle::registration(dependencies.clone()).operations);
75        batch.operations.extend(Storage::registration(dependencies.clone()).operations);
76        batch.operations.extend(Streams::registration(dependencies.clone()).operations);
77        batch.operations.extend(harmos_sdk::RegistrationBatch::new(dependencies.clone()).operation::<lifecycle::Initialize>().operations);
78        batch.operations.extend(harmos_sdk::RegistrationBatch::new(dependencies).operation::<lifecycle::Shutdown>().operations);
79        batch
80    }
81}
82
83/* === Public Functions === */
84
85/* === Private Functions === */
86
87/* === Tests === */