mangadex_api_schema_rust/v5/
upload_required_approval.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use mangadex_api_types::ResultType;
use serde::Deserialize;

use crate::FromResponse;

/// User Settings response.
#[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "non_exhaustive", non_exhaustive)]
#[allow(unused)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct UploadRequiredApproval {
    #[serde(default)]
    pub result: ResultType,
    #[serde(default)]
    pub requires_approval: Option<bool>,
}

impl From<bool> for UploadRequiredApproval {
    fn from(value: bool) -> Self {
        Self {
            result: Default::default(),
            requires_approval: Some(value),
        }
    }
}

impl UploadRequiredApproval {
    pub fn is_manga_not_found(&self) -> bool {
        self.requires_approval.is_none()
    }
}

impl From<UploadRequiredApproval> for bool {
    fn from(value: UploadRequiredApproval) -> Self {
        value.requires_approval.unwrap_or_default()
    }
}

impl FromResponse for UploadRequiredApproval {
    type Response = Self;
    fn from_response(res: Self::Response) -> Self {
        res
    }
}