app_store_server_library/models/
play_time.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
7#[serde(from = "i64", into = "i64")]
8pub enum PlayTime {
9 Undeclared,
10 ZeroToFiveMinutes,
11 FiveToSixtyMinutes,
12 OneToSixHours,
13 SixHoursToTwentyFourHours,
14 OneDayToFourDays,
15 FourDaysToSixteenDays,
16 OverSixteenDays,
17
18 NotSupported(i64),
21}
22
23impl From<i64> for PlayTime {
24 fn from(value: i64) -> Self {
25 match value {
26 0 => PlayTime::Undeclared,
27 1 => PlayTime::ZeroToFiveMinutes,
28 2 => PlayTime::FiveToSixtyMinutes,
29 3 => PlayTime::OneToSixHours,
30 4 => PlayTime::SixHoursToTwentyFourHours,
31 5 => PlayTime::OneDayToFourDays,
32 6 => PlayTime::FourDaysToSixteenDays,
33 7 => PlayTime::OverSixteenDays,
34 other => PlayTime::NotSupported(other),
35 }
36 }
37}
38
39impl From<PlayTime> for i64 {
40 fn from(value: PlayTime) -> Self {
41 match value {
42 PlayTime::Undeclared => 0,
43 PlayTime::ZeroToFiveMinutes => 1,
44 PlayTime::FiveToSixtyMinutes => 2,
45 PlayTime::OneToSixHours => 3,
46 PlayTime::SixHoursToTwentyFourHours => 4,
47 PlayTime::OneDayToFourDays => 5,
48 PlayTime::FourDaysToSixteenDays => 6,
49 PlayTime::OverSixteenDays => 7,
50 PlayTime::NotSupported(other) => other,
51 }
52 }
53}