Expand description

A simple API to make standalone Rust applications with high-level hooks for mission life-cycle management

Examples

use failure::{bail, Error};
use kubos_app::*;
use std::time::Duration;

fn main() -> Result<(), Error> {
    logging_setup!("my-app")?;

    let request = r#"mutation {
        power(state: ON) {
            success
        }
    }"#;

    match query(&ServiceConfig::new("radio-service")?, request, Some(Duration::from_secs(1))) {
        Err(error) => bail!("Failed to communicate with radio service: {}", error),
        Ok(data) => {
            if let Some(success) = data.get("power")
                .and_then(|power| power.get("success"))
            {
                match success.as_bool() {
                    Some(true) => println!("Successfully turned on radio"),
                    Some(false) => eprintln!("Failed to turn on radio"),
                    None => eprintln!("Failed to fetch radio power state")
                }
            } else {
                bail!("Failed to fetch radio power state");
            }
        }
    }
    Ok(())
}

Macros

Helper macro to set up the logger for the program

Structs

KubOS config used by either Apps or Services. KubOS config files use the TOML format, and can may contain multiple named Categories. Typically each category corresponds to an App or Service name. This allows one config file to store configuration for multiple Apps / Services at a time.

Functions

Execute a GraphQL query against a running KubOS Service using UDP.

Set up the logger for the program