1#[cfg(feature = "runtime")]
13mod error;
14pub mod host;
15pub mod lifecycle;
16pub mod storage;
17pub mod streams;
18pub mod operations {
19 pub use harmos_domain::operations::*;
20 #[cfg(feature = "lifecycle")]
21 pub use harmos_sdk::operations::{Catalog, Executable, OperationCatalog};
22}
23#[doc(hidden)]
24pub mod __private {
25 pub use harmos_domain::__private::*;
26 #[cfg(feature = "lifecycle")]
27 pub use harmos_sdk::__private::RegistrationBatch;
28}
29
30#[cfg(feature = "runtime")]
33pub use error::Error;
34pub use harmos_domain::*;
35pub use harmos_macros::{catalog, operation};
36
37#[cfg(feature = "lifecycle")]
38pub use harmos_sdk::{Context, Dependent, Executable, ExecutionContext, Operation, Resource, ResourceError, Response};
39pub use host::Host;
40pub use lifecycle::Lifecycle;
41pub use storage::Storage;
42pub use streams::Streams;
43
44extern crate self as harmos;
50
51#[cfg(feature = "runtime")]
53use harmos_sdk::__private::RegistrationBatch;
54
55#[cfg(feature = "runtime")]
58static BUILTIN_DECLARATIONS: [catalog::Node<operations::WireDeclaration>; 6] = [
59 catalog::Node::Nested(Host::CATALOG.declarations),
60 catalog::Node::Nested(Lifecycle::CATALOG.declarations),
61 catalog::Node::Nested(Storage::CATALOG.declarations),
62 catalog::Node::Nested(Streams::CATALOG.declarations),
63 catalog::Node::Leaf(operations::WireDeclaration::of::<lifecycle::Initialize>()),
64 catalog::Node::Leaf(operations::WireDeclaration::of::<lifecycle::Shutdown>()),
65];
66
67#[cfg(feature = "runtime")]
68static BUILTIN_CALLEES: [catalog::Node<&'static [operations::WireDeclaration]>; 4] = [
69 catalog::Node::Nested(Host::CATALOG.callees),
70 catalog::Node::Nested(Lifecycle::CATALOG.callees),
71 catalog::Node::Nested(Storage::CATALOG.callees),
72 catalog::Node::Nested(Streams::CATALOG.callees),
73];
74
75#[cfg(feature = "runtime")]
80pub type Result<T> = std::result::Result<T, Error>;
81
82pub struct Builtins;
85
86impl Builtins {
93 pub fn catalog() -> Vec<harmos_domain::OperationDefinition> {
94 let mut definitions = Host::catalog();
95 definitions.extend(Lifecycle::catalog());
96 definitions.extend(Storage::catalog());
97 definitions.extend(Streams::catalog());
98 definitions.push(lifecycle::Initialize::definition());
99 definitions.push(lifecycle::Shutdown::definition());
100 definitions
101 }
102}
103
104#[cfg(feature = "runtime")]
105impl harmos_sdk::operations::OperationCatalog for Builtins {
106 const CATALOG: harmos_sdk::operations::Catalog =
107 harmos_sdk::operations::Catalog::of::<Self>("harmos.builtins", &BUILTIN_DECLARATIONS, &BUILTIN_CALLEES);
108
109 fn batch() -> RegistrationBatch {
110 let mut batch = Host::batch();
111 batch.operations.extend(Lifecycle::batch().operations);
112 batch.operations.extend(Storage::batch().operations);
113 batch.operations.extend(Streams::batch().operations);
114 batch.operations.extend(RegistrationBatch::new().operation::<lifecycle::Initialize>().operations);
115 batch.operations.extend(RegistrationBatch::new().operation::<lifecycle::Shutdown>().operations);
116 batch
117 }
118}
119
120