1pub mod cli;
2pub mod loader;
3
4use std::future::Future;
5
6use clap::Args;
7use spin_core::Linker;
8use spin_factors::RuntimeFactors;
9use spin_factors_executor::{FactorsExecutorApp, FactorsInstanceBuilder};
10
11pub use spin_app::App;
12
13pub type TriggerApp<T, F> = FactorsExecutorApp<F, <T as Trigger<F>>::InstanceState>;
15
16pub type TriggerInstanceBuilder<'a, T, F> =
18 FactorsInstanceBuilder<'a, F, <T as Trigger<F>>::InstanceState>;
19
20pub type Store<T, F> = spin_core::Store<TriggerInstanceState<T, F>>;
22
23type TriggerInstanceState<T, F> = spin_factors_executor::InstanceState<
25 <F as RuntimeFactors>::InstanceState,
26 <T as Trigger<F>>::InstanceState,
27>;
28
29pub trait Trigger<F: RuntimeFactors>: Sized + Send {
31 const TYPE: &'static str;
33
34 type CliArgs: Args;
36
37 type InstanceState: Send + 'static;
39
40 fn new(cli_args: Self::CliArgs, app: &App) -> anyhow::Result<Self>;
42
43 #[doc(hidden)]
48 fn update_core_config(&mut self, config: &mut spin_core::Config) -> anyhow::Result<()> {
49 let _ = config;
50 Ok(())
51 }
52
53 fn add_to_linker(
55 &mut self,
56 linker: &mut Linker<TriggerInstanceState<Self, F>>,
57 ) -> anyhow::Result<()> {
58 let _ = linker;
59 Ok(())
60 }
61
62 fn run(
64 self,
65 trigger_app: TriggerApp<Self, F>,
66 ) -> impl Future<Output = anyhow::Result<()>> + Send;
67
68 fn supported_host_requirements() -> Vec<&'static str> {
72 Vec::new()
73 }
74}