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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// DO NOT EDIT
// This file was generated by Stone

#![allow(
    clippy::too_many_arguments,
    clippy::large_enum_variant,
    clippy::doc_markdown,
)]

/// Possible platforms on which a user may view content.
#[derive(Debug)]
pub enum PlatformType {
    /// The content was viewed on the web.
    Web,
    /// The content was viewed on a desktop client.
    Desktop,
    /// The content was viewed on a mobile iOS client.
    MobileIos,
    /// The content was viewed on a mobile android client.
    MobileAndroid,
    /// The content was viewed from an API client.
    Api,
    /// The content was viewed on an unknown platform.
    Unknown,
    /// The content was viewed on a mobile client. DEPRECATED: Use mobile_ios or mobile_android
    /// instead.
    Mobile,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for PlatformType {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = PlatformType;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a PlatformType structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "web" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PlatformType::Web)
                    }
                    "desktop" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PlatformType::Desktop)
                    }
                    "mobile_ios" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PlatformType::MobileIos)
                    }
                    "mobile_android" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PlatformType::MobileAndroid)
                    }
                    "api" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PlatformType::Api)
                    }
                    "unknown" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PlatformType::Unknown)
                    }
                    "mobile" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PlatformType::Mobile)
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(PlatformType::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["web",
                                    "desktop",
                                    "mobile_ios",
                                    "mobile_android",
                                    "api",
                                    "unknown",
                                    "mobile",
                                    "other"];
        deserializer.deserialize_struct("PlatformType", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for PlatformType {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            PlatformType::Web => {
                // unit
                let mut s = serializer.serialize_struct("PlatformType", 1)?;
                s.serialize_field(".tag", "web")?;
                s.end()
            }
            PlatformType::Desktop => {
                // unit
                let mut s = serializer.serialize_struct("PlatformType", 1)?;
                s.serialize_field(".tag", "desktop")?;
                s.end()
            }
            PlatformType::MobileIos => {
                // unit
                let mut s = serializer.serialize_struct("PlatformType", 1)?;
                s.serialize_field(".tag", "mobile_ios")?;
                s.end()
            }
            PlatformType::MobileAndroid => {
                // unit
                let mut s = serializer.serialize_struct("PlatformType", 1)?;
                s.serialize_field(".tag", "mobile_android")?;
                s.end()
            }
            PlatformType::Api => {
                // unit
                let mut s = serializer.serialize_struct("PlatformType", 1)?;
                s.serialize_field(".tag", "api")?;
                s.end()
            }
            PlatformType::Unknown => {
                // unit
                let mut s = serializer.serialize_struct("PlatformType", 1)?;
                s.serialize_field(".tag", "unknown")?;
                s.end()
            }
            PlatformType::Mobile => {
                // unit
                let mut s = serializer.serialize_struct("PlatformType", 1)?;
                s.serialize_field(".tag", "mobile")?;
                s.end()
            }
            PlatformType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}