about summary refs log tree commit diff stats
path: root/crates/rocie-client/src/apis/api_set_unit_api.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rocie-client/src/apis/api_set_unit_api.rs')
-rw-r--r--crates/rocie-client/src/apis/api_set_unit_api.rs35
1 files changed, 24 insertions, 11 deletions
diff --git a/crates/rocie-client/src/apis/api_set_unit_api.rs b/crates/rocie-client/src/apis/api_set_unit_api.rs
index 1c64bfb..93868f5 100644
--- a/crates/rocie-client/src/apis/api_set_unit_api.rs
+++ b/crates/rocie-client/src/apis/api_set_unit_api.rs
@@ -8,12 +8,10 @@
  * Generated by: https://openapi-generator.tech
  */
 
-
+use super::{ContentType, Error, configuration};
+use crate::{apis::ResponseContent, models};
 use reqwest;
 use serde::{Deserialize, Serialize, de::Error as _};
-use crate::{apis::ResponseContent, models};
-use super::{Error, configuration, ContentType};
-
 
 /// struct for typed errors of method [`register_unit`]
 #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -23,13 +21,17 @@ pub enum RegisterUnitError {
     UnknownValue(serde_json::Value),
 }
 
-
-pub async fn register_unit(configuration: &configuration::Configuration, unit_stub: models::UnitStub) -> Result<models::UnitId, Error<RegisterUnitError>> {
+pub async fn register_unit(
+    configuration: &configuration::Configuration,
+    unit_stub: models::UnitStub,
+) -> Result<models::UnitId, Error<RegisterUnitError>> {
     // add a prefix to parameters to efficiently prevent name collisions
     let p_unit_stub = unit_stub;
 
     let uri_str = format!("{}/unit/new", configuration.base_path);
-    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
+    let mut req_builder = configuration
+        .client
+        .request(reqwest::Method::POST, &uri_str);
 
     if let Some(ref user_agent) = configuration.user_agent {
         req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
@@ -51,13 +53,24 @@ pub async fn register_unit(configuration: &configuration::Configuration, unit_st
         let content = resp.text().await?;
         match content_type {
             ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
-            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UnitId`"))),
-            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UnitId`")))),
+            ContentType::Text => {
+                return Err(Error::from(serde_json::Error::custom(
+                    "Received `text/plain` content type response that cannot be converted to `models::UnitId`",
+                )));
+            }
+            ContentType::Unsupported(unknown_type) => {
+                return Err(Error::from(serde_json::Error::custom(format!(
+                    "Received `{unknown_type}` content type response that cannot be converted to `models::UnitId`"
+                ))));
+            }
         }
     } else {
         let content = resp.text().await?;
         let entity: Option<RegisterUnitError> = serde_json::from_str(&content).ok();
-        Err(Error::ResponseError(ResponseContent { status, content, entity }))
+        Err(Error::ResponseError(ResponseContent {
+            status,
+            content,
+            entity,
+        }))
     }
 }
-