Skip to main content

03_application_contract/
application_contract.rs

1// =============================================================================
2//        #######
3//     ###       ###     F: application_contract.rs
4//    ##   ## ##   ##    P: AppCore-Runtime
5//         ## ##
6//                       C: 2026/09/04 00:00:00 by dnettoRaw
7//    ##   ## ##   ##    U: 2026/09/04 00:00:00 by dnettoRaw
8//      ###########      S: 1.0.0-rc.1
9// =============================================================================
10
11//! Declare business contracts without constructing Runtime infrastructure.
12//!
13//! An application registers its own behavior while `AppCore` owns the generic
14//! Runtime lifecycle and infrastructure.
15
16use appcore_sdk::application::{CommandName, CommandRegistry, NodeId, RuntimeResult};
17use appcore_sdk::{App, AppResult, Application};
18
19struct ReportingApp;
20
21impl Application for ReportingApp {
22    fn register_commands(&self, registry: &mut CommandRegistry) -> RuntimeResult<()> {
23        // Command names describe business behavior without starting a host.
24        registry.register(CommandName::new("report.generate")?)
25    }
26}
27
28fn main() -> AppResult<()> {
29    let app = App::new("reporting")?;
30    let prepared = app.prepare(&ReportingApp, NodeId::new("reporting-local")?)?;
31
32    assert_eq!(prepared.runtime().commands().len(), 1);
33
34    Ok(())
35}