kubos_app/
lib.rs

1/*
2 * Copyright (C) 2018 Kubos Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//! A simple API to make standalone Rust applications with high-level hooks
18//! for mission life-cycle management
19//!
20//! # Examples
21//!
22//! ```ignore
23//! use failure::{bail, Error};
24//! use kubos_app::*;
25//! use std::time::Duration;
26//!
27//! fn main() -> Result<(), Error> {
28//!     logging_setup!("my-app")?;
29//!
30//!     let request = r#"mutation {
31//!         power(state: ON) {
32//!             success
33//!         }
34//!     }"#;
35//!
36//!     match query(&ServiceConfig::new("radio-service")?, request, Some(Duration::from_secs(1))) {
37//!         Err(error) => bail!("Failed to communicate with radio service: {}", error),
38//!         Ok(data) => {
39//!             if let Some(success) = data.get("power")
40//!                 .and_then(|power| power.get("success"))
41//!             {
42//!                 match success.as_bool() {
43//!                     Some(true) => println!("Successfully turned on radio"),
44//!                     Some(false) => eprintln!("Failed to turn on radio"),
45//!                     None => eprintln!("Failed to fetch radio power state")
46//!                 }
47//!             } else {
48//!                 bail!("Failed to fetch radio power state");
49//!             }
50//!         }
51//!     }
52//!     Ok(())
53//! }
54//! ```
55//!
56
57#![deny(missing_docs)]
58#![deny(warnings)]
59
60#[cfg(test)]
61#[macro_use]
62extern crate juniper;
63
64mod framework;
65mod query;
66#[cfg(test)]
67mod tests;
68
69pub use crate::framework::*;
70pub use crate::query::query;
71pub use kubos_system::Config as ServiceConfig;