116 lines
2.4 KiB
Rust
116 lines
2.4 KiB
Rust
use ron::{
|
|
de::from_bytes,
|
|
ser::{to_string_pretty, PrettyConfig},
|
|
};
|
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
|
|
|
///// RECIPE /////
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct SetRecipeTitle {
|
|
pub recipe_id: i64,
|
|
pub title: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct SetRecipeDescription {
|
|
pub recipe_id: i64,
|
|
pub description: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct AddRecipeImage {
|
|
pub recipe_id: i64,
|
|
pub image: Vec<u8>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct AddRecipeImageReply {
|
|
pub image_id: i64,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct RemoveRecipeImage {
|
|
pub image_id: i64,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct AddRecipeIngredient {
|
|
pub group_id: i64,
|
|
pub name: String,
|
|
pub quantity_value: Option<f64>,
|
|
pub quantity_unit: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct AddRecipeIngredientReply {
|
|
pub ingredient_id: i64,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct RemoveRecipeIngredient {
|
|
pub group_id: i64,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct SetRecipeIngredientsOrder {
|
|
pub group_id: i64,
|
|
pub ingredient_ids: Vec<i64>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct AddRecipeGroup {
|
|
pub recipe_id: i64,
|
|
pub name: String,
|
|
pub quantity_value: Option<f64>,
|
|
pub quantity_unit: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct AddRecipeGroupReply {
|
|
pub group_id: i64,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct RemoveRecipeGroupReply {
|
|
pub group_id: i64,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct SetRecipeGroupsOrder {
|
|
pub recipe_id: i64,
|
|
pub group_ids: Vec<i64>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct AddRecipeStep {
|
|
pub group_id: i64,
|
|
pub name: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct AddRecipeStepReply {
|
|
pub step_id: i64,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct RemoveRecipeStep {
|
|
pub step_id: i64,
|
|
}
|
|
|
|
///// PROFILE /////
|
|
|
|
#[derive(Serialize, Deserialize, Clone)]
|
|
pub struct UpdateProfile {
|
|
pub name: Option<String>,
|
|
pub email: Option<String>,
|
|
pub password: Option<String>,
|
|
}
|
|
|
|
pub fn to_string<T>(ron: T) -> String
|
|
where
|
|
T: Serialize,
|
|
{
|
|
// TODO: handle'unwrap'.
|
|
to_string_pretty(&ron, PrettyConfig::new()).unwrap()
|
|
}
|