mz_frontegg_mock/models/
utils.rs1use serde::Serialize;
11
12#[derive(Serialize)]
13pub struct ErrorResponse {
14 pub errors: Vec<String>,
15}
16
17#[derive(Debug, PartialEq)]
18pub enum SortBy {
19 Email,
20 Id,
21}
22
23#[derive(Debug, PartialEq)]
24pub enum Order {
25 ASC,
26 DESC,
27}
28
29impl TryFrom<&str> for Order {
30 type Error = String;
31
32 fn try_from(value: &str) -> Result<Self, Self::Error> {
33 match value.to_uppercase().as_str() {
34 "ASC" => Ok(Order::ASC),
35 "DESC" => Ok(Order::DESC),
36 _ => Err(format!("'{}' is not a valid order option", value)),
37 }
38 }
39}
40
41impl TryFrom<&str> for SortBy {
42 type Error = String;
43
44 fn try_from(value: &str) -> Result<Self, Self::Error> {
45 match value {
46 "email" => Ok(SortBy::Email),
47 "id" => Ok(SortBy::Id),
48 _ => Err(format!("'{}' is not a valid sort option", value)),
49 }
50 }
51}