[][src]Macro kubos_app::app_main

macro_rules! app_main {
    ($handler:expr) => { ... };
    ($handler:expr, $level:expr) => { ... };
}

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

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(())
}