Add a API entry point to get all tags
This commit is contained in:
parent
6e017e41a3
commit
c24b0caeaf
7 changed files with 55 additions and 63 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use chrono::NaiveDate;
|
||||
use ron::ser::{PrettyConfig, to_string_pretty};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum::FromRepr;
|
||||
|
||||
/*** Generic types ***/
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ pub struct DateRange {
|
|||
/*** Recipe ***/
|
||||
|
||||
#[repr(u32)]
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Debug)]
|
||||
#[derive(Serialize, Deserialize, FromRepr, Clone, Copy, PartialEq, Debug)]
|
||||
pub enum Difficulty {
|
||||
Unknown = 0,
|
||||
Easy = 1,
|
||||
|
|
@ -29,14 +30,9 @@ pub enum Difficulty {
|
|||
}
|
||||
|
||||
impl TryFrom<u32> for Difficulty {
|
||||
type Error = &'static str;
|
||||
type Error = String;
|
||||
fn try_from(value: u32) -> Result<Self, Self::Error> {
|
||||
Ok(match value {
|
||||
1 => Self::Easy,
|
||||
2 => Self::Medium,
|
||||
3 => Self::Hard,
|
||||
_ => Self::Unknown,
|
||||
})
|
||||
Difficulty::from_repr(value).ok_or(format!("Unable to convert difficulty from {}", value))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue