Skip to main content

exocore_apps_sdk/
app.rs

1use crate::client::Exocore;
2
3/// Trait implemented by an application WASM module. The struct implementing
4/// this trait should have the `#[exocore_app]` macro attribute.
5pub trait App: Send {
6    fn start(&self, client: &Exocore) -> Result<(), AppError>;
7}
8
9// Called by #[exocore_app] macro at application initialization.
10pub fn __exocore_app_register(app: Box<dyn App>) {
11    let exocore = Exocore::get();
12    exocore.register_app(app);
13}
14
15pub(crate) fn boot_app() {
16    let exocore = Exocore::get();
17    exocore.with_app(|app| app.start(exocore).expect("Failed to start application"))
18}
19
20#[derive(Debug, thiserror::Error)]
21pub enum AppError {
22    #[error(transparent)]
23    Other(#[from] anyhow::Error),
24}