Skip to main content

bitwarden_api_api/models/
event_system_user.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor};
12
13use crate::models;
14///
15#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16pub enum EventSystemUser {
17    Unknown,
18    SCIM,
19    DomainVerification,
20    PublicApi,
21    TwoFactorDisabled,
22    BitwardenPortal,
23    Pam,
24    ScheduledJob,
25
26    /// Unknown value returned from the server. This is used to handle forward compatibility.
27    __Unknown(i64),
28}
29
30impl EventSystemUser {
31    pub fn as_i64(&self) -> i64 {
32        match self {
33            Self::Unknown => 0,
34            Self::SCIM => 1,
35            Self::DomainVerification => 2,
36            Self::PublicApi => 3,
37            Self::TwoFactorDisabled => 4,
38            Self::BitwardenPortal => 5,
39            Self::Pam => 6,
40            Self::ScheduledJob => 7,
41            Self::__Unknown(v) => *v,
42        }
43    }
44
45    pub fn from_i64(value: i64) -> Self {
46        match value {
47            0 => Self::Unknown,
48            1 => Self::SCIM,
49            2 => Self::DomainVerification,
50            3 => Self::PublicApi,
51            4 => Self::TwoFactorDisabled,
52            5 => Self::BitwardenPortal,
53            6 => Self::Pam,
54            7 => Self::ScheduledJob,
55            v => Self::__Unknown(v),
56        }
57    }
58}
59
60impl serde::Serialize for EventSystemUser {
61    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
62        serializer.serialize_i64(self.as_i64())
63    }
64}
65
66impl<'de> serde::Deserialize<'de> for EventSystemUser {
67    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
68        struct EventSystemUserVisitor;
69
70        impl Visitor<'_> for EventSystemUserVisitor {
71            type Value = EventSystemUser;
72
73            fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
74                f.write_str("an integer")
75            }
76
77            fn visit_i64<E: serde::de::Error>(self, v: i64) -> Result<Self::Value, E> {
78                Ok(EventSystemUser::from_i64(v))
79            }
80
81            fn visit_u64<E: serde::de::Error>(self, v: u64) -> Result<Self::Value, E> {
82                Ok(EventSystemUser::from_i64(v as i64))
83            }
84        }
85
86        deserializer.deserialize_i64(EventSystemUserVisitor)
87    }
88}
89
90impl std::fmt::Display for EventSystemUser {
91    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
92        write!(f, "{}", self.as_i64())
93    }
94}
95impl Default for EventSystemUser {
96    fn default() -> EventSystemUser {
97        Self::Unknown
98    }
99}