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_get_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_get_recipe_api.rs')
| -rw-r--r-- | crates/rocie-client/src/apis/api_get_recipe_api.rs | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/crates/rocie-client/src/apis/api_get_recipe_api.rs b/crates/rocie-client/src/apis/api_get_recipe_api.rs index f29a2ce..321e3a1 100644 --- a/crates/rocie-client/src/apis/api_get_recipe_api.rs +++ b/crates/rocie-client/src/apis/api_get_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 [`recipe_by_id`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -32,12 +30,18 @@ pub enum RecipesError { UnknownValue(serde_json::Value), } - -pub async fn recipe_by_id(configuration: &configuration::Configuration, id: models::RecipeId) -> Result<models::Recipe, Error<RecipeByIdError>> { +pub async fn recipe_by_id( + configuration: &configuration::Configuration, + id: models::RecipeId, +) -> Result<models::Recipe, Error<RecipeByIdError>> { // add a prefix to parameters to efficiently prevent name collisions let p_id = id; - let uri_str = format!("{}/recipe/by-id/{id}", configuration.base_path, id=p_id.to_string()); + let uri_str = format!( + "{}/recipe/by-id/{id}", + configuration.base_path, + id = p_id.to_string() + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -59,18 +63,31 @@ pub async fn recipe_by_id(configuration: &configuration::Configuration, id: mode 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::Recipe`"))), - 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::Recipe`")))), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::Recipe`", + ))); + } + 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::Recipe`" + )))); + } } } else { let content = resp.text().await?; let entity: Option<RecipeByIdError> = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { status, content, entity })) + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } -pub async fn recipes(configuration: &configuration::Configuration, ) -> Result<models::Recipe, Error<RecipesError>> { - +pub async fn recipes( + configuration: &configuration::Configuration, +) -> Result<models::Recipe, Error<RecipesError>> { let uri_str = format!("{}/recipe/all", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -93,13 +110,24 @@ pub async fn recipes(configuration: &configuration::Configuration, ) -> Result<m 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::Recipe`"))), - 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::Recipe`")))), + ContentType::Text => { + return Err(Error::from(serde_json::Error::custom( + "Received `text/plain` content type response that cannot be converted to `models::Recipe`", + ))); + } + 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::Recipe`" + )))); + } } } else { let content = resp.text().await?; let entity: Option<RecipesError> = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { status, content, entity })) + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) } } - |
