Recipe edit (WIP): add API to set some recipe values

This commit is contained in:
Greg Burri 2024-12-23 01:37:01 +01:00
parent c6dfff065c
commit dd05a673d9
20 changed files with 690 additions and 2189 deletions

View file

@ -1,4 +1,5 @@
use chrono::prelude::*;
use common::ron_api::Difficulty;
use sqlx::{self, FromRow};
#[derive(Debug, Clone, FromRow)]
@ -50,29 +51,3 @@ pub struct Ingredient {
pub quantity: i32,
pub quantity_unit: String,
}
#[derive(PartialEq, Debug)]
pub enum Difficulty {
Unknown = 0,
Easy = 1,
Medium = 2,
Hard = 3,
}
impl TryFrom<u32> for Difficulty {
type Error = &'static str;
fn try_from(value: u32) -> Result<Self, Self::Error> {
Ok(match value {
1 => Self::Easy,
2 => Self::Medium,
3 => Self::Hard,
_ => Self::Unknown,
})
}
}
impl From<Difficulty> for u32 {
fn from(value: Difficulty) -> Self {
value as u32
}
}