harmos_runtime/
application.rs1use std::sync::Arc;
18
19use crate::{Handle, Lifecycle, ResourceError};
23
24pub struct Startup<A: Application> {
33 pub runtime: Handle<A>,
34}
35
36pub trait Application: Lifecycle<Context = Startup<Self>> + Sync {
41 type Lanes: crate::operations::Lane;
42
43 type State: Send + Sync + 'static;
44
45 type Transaction: crate::state::Transaction<Self::State, Error: Send + Sync + 'static>
46 + crate::state::TransactionCatalog<Self::State>
47 + Send
48 + Sync
49 + 'static;
50
51 type Record: crate::state::RecordCatalog + Send + Sync + 'static;
52
53 type Streams: Send + Sync + 'static;
54}
55
56impl<A: Application> Clone for Startup<A> {
59 fn clone(&self) -> Self {
60 Self { runtime: self.runtime.clone() }
61 }
62}
63
64impl<A: Application> harmos_sdk::lifecycle::Context for Startup<A> {
65 type Configuration = crate::runtime::Builder<A>;
66}
67
68impl<A: Application> Startup<A> {
69 pub fn resource<T: Send + Sync + 'static>(&self) -> Result<Arc<T>, ResourceError> {
70 self.runtime.operations.context().resource::<T>()
71 }
72}
73
74