diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-12-09 13:12:31 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-12-09 13:12:31 +0100 |
| commit | 7565c34d69ee259fef3ac9813d689d97689a6d58 (patch) | |
| tree | ee4f00e3d090ec288d481cc92781e55637619824 /crates/rocie-client/src/apis/api_set_recipe_api.rs | |
| parent | feat(rocie-server): Implement basic user handling and authentication (diff) | |
| download | server-7565c34d69ee259fef3ac9813d689d97689a6d58.zip | |
style(rocie-client): Format
Diffstat (limited to 'crates/rocie-client/src/apis/api_set_recipe_api.rs')
| -rw-r--r-- | crates/rocie-client/src/apis/api_set_recipe_api.rs | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/crates/rocie-client/src/apis/api_set_recipe_api.rs b/crates/rocie-client/src/apis/api_set_recipe_api.rs index 519f90e..299cad0 100644 --- a/crates/rocie-client/src/apis/api_set_recipe_api.rs +++ b/crates/rocie-client/src/apis/api_set_recipe_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 [`add_recipe`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -23,13 +21,17 @@ pub enum AddRecipeError { UnknownValue(serde_json::Value), } - -pub async fn add_recipe(configuration: &configuration::Configuration, recipe_stub: models::RecipeStub) -> Result<models::RecipeId, Error<AddRecipeError>> { +pub async fn add_recipe( + configuration: &configuration::Configuration, + recipe_stub: models::RecipeStub, +) -> Result<models::RecipeId, Error<AddRecipeError>> { // add a prefix to parameters to efficiently prevent name collisions let p_recipe_stub = recipe_stub; let uri_str = format!("{}/recipe/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 add_recipe(configuration: &configuration::Configuration, recipe_stu 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::RecipeId`"))), - 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::RecipeId`")))), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::RecipeId`", + ))); + } + 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::RecipeId`" + )))); + } } } else { let content = resp.text().await?; let entity: Option<AddRecipeError> = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { status, content, entity })) + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } - |
