[−][src]Macro kubos_app::app_main
A helper macro which detects the requested run level and calls the appropriate handler function.
Logging will be set up automatically for the application.
The log name will be taken from the package name specified in the application's Cargo.toml
file.
Note: Any hyphens will be automatically converted to underscores (test-app
-> test_app
)
Arguments
handler
- A reference to an object which implements the run level handler functionslevel
- Default:log::LevelFilter::Debug
. The minimum log level to record
Examples
use failure::Error; use kubos_app::{AppHandler, app_main}; struct MyApp; impl AppHandler for MyApp { fn on_boot(&self, _args: Vec<String>) -> Result<(), Error> { println!("OnBoot logic"); Ok(()) } fn on_command(&self, _args: Vec<String>) -> Result<(), Error> { println!("OnCommand logic"); Ok(()) } } fn main() -> Result<(), Error> { let app = MyApp { }; app_main!(&app)?; Ok(()) }