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
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
use super::GetFlag;
use super::{GetFlag::*, Results};
use serde::Deserialize;
use serde_repr::Deserialize_repr;

/// All valid flags for get release method
pub const RELEASE_FLAGS: [GetFlag; 4] = [Basic, Details, Vn, Producers];

/// Results returned from get release method
#[derive(Deserialize, Debug, PartialEq)]
pub struct GetReleaseResults {
    #[serde(flatten)]
    pub results: Results,
    pub items: Vec<GetReleaseResponse>,
}

/// All fields returned by get release method
/// fields are either Some or None depending on GetFlag param passed to get function
#[derive(Deserialize, Debug, PartialEq)]
pub struct GetReleaseResponse {
    pub id: usize,
    pub title: Option<String>,
    #[serde(rename = "original")]
    pub original_title: Option<String>,
    pub released: Option<String>,
    #[serde(rename = "type")]
    pub release_type: Option<ReleaseType>,
    pub patch: Option<bool>,
    pub freeware: Option<bool>,
    pub doujin: Option<bool>,
    pub languages: Option<Vec<String>>,
    pub website: Option<String>,
    pub notes: Option<String>,
    #[serde(rename = "minage")]
    pub age_rating: Option<u8>,
    #[serde(rename = "gtin")]
    pub barcode: Option<String>,
    pub catalog: Option<String>,
    pub platforms: Option<Vec<String>>,
    pub media: Option<Vec<Media>>,
    // TODO deserialize to struct
    pub resolution: Option<String>,
    pub voiced: Option<Voiced>,
    // TODO deserialize to struct
    pub animation: Option<Vec<Option<Animation>>>,
    pub vn: Option<Vec<Vn>>,
    pub producers: Option<Vec<Producers>>,
}

/// Release type
#[derive(Deserialize, Debug, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum ReleaseType {
    Complete,
    Partial,
    Trial,
}

/// Release media
#[derive(Deserialize, Debug, PartialEq)]
pub struct Media {
    pub medium: String,
    #[serde(rename = "qty")]
    pub quantity: Option<usize>,
}

/// VN voice acting type
#[repr(u8)]
#[derive(Deserialize_repr, Debug, PartialEq)]
pub enum Voiced {
    NotVoiced = 1,
    OnlyEro = 2,
    PartVoiced = 3,
    FullVoiced = 4,
}

/// Types of animations
#[repr(u8)]
#[derive(Deserialize_repr, Debug, PartialEq)]
pub enum Animation {
    NoAnimations = 1,
    SimpleAnimations = 2,
    SomeFullyAnimatedScenes = 3,
    FullyAnimated = 4,
}

/// Visual novel linked to this release.
#[derive(Deserialize, Debug, PartialEq)]
pub struct Vn {
    pub id: usize,
    pub title: String,
    #[serde(rename = "original")]
    pub original_title: Option<String>,
}

/// Producer involved in this release.
#[derive(Deserialize, Debug, PartialEq)]
pub struct Producers {
    pub id: usize,
    pub developer: bool,
    pub publisher: bool,
    pub name: String,
    #[serde(rename = "original")]
    pub original_name: Option<String>,
    #[serde(rename = "type")]
    pub producer_type: String,
}