1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
910use serde::Serialize;
1112#[derive(Serialize)]
13pub struct ErrorResponse {
14pub errors: Vec<String>,
15}
1617#[derive(Debug, PartialEq)]
18pub enum SortBy {
19 Email,
20 Id,
21}
2223#[derive(Debug, PartialEq)]
24pub enum Order {
25 ASC,
26 DESC,
27}
2829impl TryFrom<&str> for Order {
30type Error = String;
3132fn try_from(value: &str) -> Result<Self, Self::Error> {
33match 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}
4041impl TryFrom<&str> for SortBy {
42type Error = String;
4344fn try_from(value: &str) -> Result<Self, Self::Error> {
45match value {
46"email" => Ok(SortBy::Email),
47"id" => Ok(SortBy::Id),
48_ => Err(format!("'{}' is not a valid sort option", value)),
49 }
50 }
51}