Crates.io | kubos-app |
lib.rs | kubos-app |
version | 0.1.0 |
source | src |
created_at | 2022-12-23 05:26:14.397662 |
updated_at | 2022-12-23 05:26:14.397662 |
description | KubOS: Linux-based OS and middleware for Satellites |
homepage | |
repository | https://github.com/kubos/kubos |
max_upload_size | |
id | 744285 |
size | 18,924 |
The Rust application API is meant to simplify development of KubOS mission applications in Rust.
It provides the following functionality:
use failure::{bail, Error};
use kubos_app::*;
use log::*;
fn main() -> Result<(), Error> {
// Initialize logging
logging_setup!("my-rust-app");
// GraphQL request to turn on the radio
let request = r#"mutation {
power(state: ON) {
success
}
}"#;
// Send the GraphQL request to the radio sevice
match query(&ServiceConfig::new("radio-service")?, request, Some(Duration::from_secs(1))) {
Err(error) => bail!("Failed to communicate with radio service: {}", error),
Ok(data) => {
// Parse the response to verify that the operation was
// successful
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(())
}