qcs_api_client_openapi/
lib.rs

1// Copyright 2022 Rigetti Computing
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! # QCS OpenAPI client for Rust
16//!
17//! This crate is autogenerated.
18//!
19//! ## Quick Start example
20//!
21//! ```no_run
22//! use qcs_api_client_openapi::apis::configuration::Configuration;
23//! use qcs_api_client_openapi::apis::default_api::get_health;
24//! # #[tokio::main]
25//! # async fn main() {
26//! let config = Configuration::new().await.expect("should not fail to load config");
27//! get_health(&config).await.expect("API should be healthy");
28//! # }
29//! ```
30
31#![allow(clippy::derive_partial_eq_without_eq)]
32#![allow(suspicious_double_ref_op)]
33#![allow(clippy::clone_on_copy)]
34#![allow(clippy::too_many_arguments)]
35#![allow(noop_method_call)]
36
37pub use reqwest;
38
39pub use serde;
40pub use serde_json;
41pub use url;
42pub mod apis;
43pub mod models;
44pub use qcs_api_client_common as common;
45
46#[cfg(feature = "clap")]
47pub mod clap_utils {
48    use serde::de::DeserializeOwned;
49    use std::str::FromStr;
50
51    pub type JsonMaybeStdin<T> = clap_stdin::MaybeStdin<JsonFromStr<T>>;
52
53    #[derive(Debug, Clone)]
54    pub struct JsonFromStr<T>(T)
55    where
56        T: Clone + DeserializeOwned;
57
58    impl<T> FromStr for JsonFromStr<T>
59    where
60        T: Clone + DeserializeOwned,
61    {
62        type Err = anyhow::Error;
63
64        fn from_str(s: &str) -> Result<Self, Self::Err> {
65            let d = &mut serde_json::Deserializer::from_str(s);
66            let v = serde_path_to_error::deserialize(d).map_err(|e| {
67                let full_type_name = std::any::type_name::<T>();
68                let simple_type_name = full_type_name.rsplit("::").next().unwrap_or(full_type_name);
69                anyhow::anyhow!("Failed to parse {}: {}", simple_type_name, e)
70            })?;
71            Ok(Self(v))
72        }
73    }
74
75    impl<T> JsonFromStr<T>
76    where
77        T: Clone + DeserializeOwned,
78    {
79        pub fn into_inner(self) -> T {
80            self.0
81        }
82    }
83}