Skip to main content

app_store_server_library/models/
user_status.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
4#[serde(from = "i64", into = "i64")]
5pub enum UserStatus {
6    Undeclared,
7    Active,
8    Suspended,
9    Terminated,
10    LimitedAccess,
11
12    /// A value the App Store sent that this version of the
13    /// library does not support, preserved as received.
14    NotSupported(i64),
15}
16
17impl From<i64> for UserStatus {
18    fn from(value: i64) -> Self {
19        match value {
20            0 => UserStatus::Undeclared,
21            1 => UserStatus::Active,
22            2 => UserStatus::Suspended,
23            3 => UserStatus::Terminated,
24            4 => UserStatus::LimitedAccess,
25            other => UserStatus::NotSupported(other),
26        }
27    }
28}
29
30impl From<UserStatus> for i64 {
31    fn from(value: UserStatus) -> Self {
32        match value {
33            UserStatus::Undeclared => 0,
34            UserStatus::Active => 1,
35            UserStatus::Suspended => 2,
36            UserStatus::Terminated => 3,
37            UserStatus::LimitedAccess => 4,
38            UserStatus::NotSupported(other) => other,
39        }
40    }
41}