booru/client/
generic.rs

1use crate::model::{
2    danbooru::DanbooruRating, gelbooru::GelbooruRating, rule34::Rule34Rating,
3    safebooru::SafebooruRating,
4};
5use serde::{Deserialize, Serialize};
6use std::fmt;
7
8pub enum Rating {
9    Danbooru(DanbooruRating),
10    Gelbooru(GelbooruRating),
11    Safebooru(SafebooruRating),
12    Rule34(Rule34Rating),
13}
14
15impl From<DanbooruRating> for Rating {
16    fn from(value: DanbooruRating) -> Self {
17        Rating::Danbooru(value)
18    }
19}
20
21impl From<GelbooruRating> for Rating {
22    fn from(value: GelbooruRating) -> Self {
23        Rating::Gelbooru(value)
24    }
25}
26
27impl From<SafebooruRating> for Rating {
28    fn from(value: SafebooruRating) -> Self {
29        Rating::Safebooru(value)
30    }
31}
32
33impl From<Rule34Rating> for Rating {
34    fn from(value: Rule34Rating) -> Self {
35        Rating::Rule34(value)
36    }
37}
38
39#[derive(Debug, Clone)]
40pub enum Sort {
41    Id,
42    Score,
43    Rating,
44    User,
45    Height,
46    Width,
47    Source,
48    Updated,
49}
50
51impl fmt::Display for Sort {
52    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
53        let lowercase_tag = format!("{:?}", self).to_lowercase();
54        write!(f, "{lowercase_tag}")
55    }
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
59pub struct AutoCompleteItem {
60    pub value: String,
61    pub label: String,
62}