mango_api/requests/
tag.rs

1//! Utilities for tag specific server part of the application.
2//!
3//! The meaning of most of the confusing structs here can be found at <https://api.mangadex.org/docs/3-enumerations/#manga-links-data>
4//!
5//! All queries encountered here can be constructed with the builder syntax from the [bon] crate
6
7use serde::{Deserialize, Serialize};
8
9use super::query_utils::{LocalizedString, Relationship};
10use super::{Entity, EntityType};
11
12/// Used for serialization/deserialization
13#[derive(Serialize, Deserialize, Debug, Clone)]
14#[serde(rename_all = "snake_case")]
15pub enum TagGroup {
16    Content,
17    Format,
18    Genre,
19    Theme,
20}
21
22/// Used for serialization/deserialization
23#[derive(Serialize, Deserialize, Debug, Clone)]
24pub struct TagAttributes {
25    pub name: LocalizedString,
26    pub description: LocalizedString,
27    pub group: TagGroup,
28    pub version: usize,
29}
30
31/// Main structure used for representing the response containg tag info
32#[derive(Serialize, Deserialize, Debug, Clone)]
33pub struct Tag {
34    pub id: String,
35    #[serde(rename(deserialize = "type"))]
36    pub entity_type: EntityType,
37    pub attributes: TagAttributes,
38    pub relationships: Vec<Relationship>,
39}
40
41impl Entity for Tag {}
42
43/// Used for serialization/deserialization
44#[derive(Serialize, Deserialize, Debug, Clone)]
45#[serde(rename_all = "UPPERCASE")]
46pub enum TagsMode {
47    And,
48    Or,
49}