Skip to main content

dropbox_sdk/generated/types/
users.rs

1// DO NOT EDIT
2// This file was @generated by Stone
3
4#![allow(
5    clippy::too_many_arguments,
6    clippy::large_enum_variant,
7    clippy::result_large_err,
8    clippy::doc_markdown,
9    clippy::doc_lazy_continuation,
10)]
11
12//! This namespace contains endpoints and data types for user management.
13
14pub type GetAccountBatchResult = Vec<BasicAccount>;
15
16/// The amount of detail revealed about an account depends on the user being queried and the user
17/// making the query.
18#[derive(Debug, Clone, PartialEq, Eq)]
19#[non_exhaustive] // structs may have more fields added in the future.
20pub struct Account {
21    /// The user's unique Dropbox ID.
22    pub account_id: crate::types::users_common::AccountId,
23    /// Details of a user's name.
24    pub name: Name,
25    /// The user's email address. Do not rely on this without checking the `email_verified` field.
26    /// Even then, it's possible that the user has since lost access to their email.
27    pub email: String,
28    /// Whether the user has verified their email address.
29    pub email_verified: bool,
30    /// Whether the user has been disabled.
31    pub disabled: bool,
32    /// URL for the photo representing the user, if one is set.
33    pub profile_photo_url: Option<String>,
34}
35
36impl Account {
37    pub fn new(
38        account_id: crate::types::users_common::AccountId,
39        name: Name,
40        email: String,
41        email_verified: bool,
42        disabled: bool,
43    ) -> Self {
44        Account {
45            account_id,
46            name,
47            email,
48            email_verified,
49            disabled,
50            profile_photo_url: None,
51        }
52    }
53
54    pub fn with_profile_photo_url(mut self, value: String) -> Self {
55        self.profile_photo_url = Some(value);
56        self
57    }
58}
59
60const ACCOUNT_FIELDS: &[&str] = &["account_id",
61                                  "name",
62                                  "email",
63                                  "email_verified",
64                                  "disabled",
65                                  "profile_photo_url"];
66impl Account {
67    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
68        map: V,
69    ) -> Result<Account, V::Error> {
70        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
71    }
72
73    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
74        mut map: V,
75        optional: bool,
76    ) -> Result<Option<Account>, V::Error> {
77        let mut field_account_id = None;
78        let mut field_name = None;
79        let mut field_email = None;
80        let mut field_email_verified = None;
81        let mut field_disabled = None;
82        let mut field_profile_photo_url = None;
83        let mut nothing = true;
84        while let Some(key) = map.next_key::<&str>()? {
85            nothing = false;
86            match key {
87                "account_id" => {
88                    if field_account_id.is_some() {
89                        return Err(::serde::de::Error::duplicate_field("account_id"));
90                    }
91                    field_account_id = Some(map.next_value()?);
92                }
93                "name" => {
94                    if field_name.is_some() {
95                        return Err(::serde::de::Error::duplicate_field("name"));
96                    }
97                    field_name = Some(map.next_value()?);
98                }
99                "email" => {
100                    if field_email.is_some() {
101                        return Err(::serde::de::Error::duplicate_field("email"));
102                    }
103                    field_email = Some(map.next_value()?);
104                }
105                "email_verified" => {
106                    if field_email_verified.is_some() {
107                        return Err(::serde::de::Error::duplicate_field("email_verified"));
108                    }
109                    field_email_verified = Some(map.next_value()?);
110                }
111                "disabled" => {
112                    if field_disabled.is_some() {
113                        return Err(::serde::de::Error::duplicate_field("disabled"));
114                    }
115                    field_disabled = Some(map.next_value()?);
116                }
117                "profile_photo_url" => {
118                    if field_profile_photo_url.is_some() {
119                        return Err(::serde::de::Error::duplicate_field("profile_photo_url"));
120                    }
121                    field_profile_photo_url = Some(map.next_value()?);
122                }
123                _ => {
124                    // unknown field allowed and ignored
125                    map.next_value::<::serde_json::Value>()?;
126                }
127            }
128        }
129        if optional && nothing {
130            return Ok(None);
131        }
132        let result = Account {
133            account_id: field_account_id.ok_or_else(|| ::serde::de::Error::missing_field("account_id"))?,
134            name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
135            email: field_email.ok_or_else(|| ::serde::de::Error::missing_field("email"))?,
136            email_verified: field_email_verified.ok_or_else(|| ::serde::de::Error::missing_field("email_verified"))?,
137            disabled: field_disabled.ok_or_else(|| ::serde::de::Error::missing_field("disabled"))?,
138            profile_photo_url: field_profile_photo_url.and_then(Option::flatten),
139        };
140        Ok(Some(result))
141    }
142
143    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
144        &self,
145        s: &mut S::SerializeStruct,
146    ) -> Result<(), S::Error> {
147        use serde::ser::SerializeStruct;
148        s.serialize_field("account_id", &self.account_id)?;
149        s.serialize_field("name", &self.name)?;
150        s.serialize_field("email", &self.email)?;
151        s.serialize_field("email_verified", &self.email_verified)?;
152        s.serialize_field("disabled", &self.disabled)?;
153        if let Some(val) = &self.profile_photo_url {
154            s.serialize_field("profile_photo_url", val)?;
155        }
156        Ok(())
157    }
158}
159
160impl<'de> ::serde::de::Deserialize<'de> for Account {
161    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
162        // struct deserializer
163        use serde::de::{MapAccess, Visitor};
164        struct StructVisitor;
165        impl<'de> Visitor<'de> for StructVisitor {
166            type Value = Account;
167            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
168                f.write_str("a Account struct")
169            }
170            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
171                Account::internal_deserialize(map)
172            }
173        }
174        deserializer.deserialize_struct("Account", ACCOUNT_FIELDS, StructVisitor)
175    }
176}
177
178impl ::serde::ser::Serialize for Account {
179    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
180        // struct serializer
181        use serde::ser::SerializeStruct;
182        let mut s = serializer.serialize_struct("Account", 6)?;
183        self.internal_serialize::<S>(&mut s)?;
184        s.end()
185    }
186}
187
188/// Basic information about any account.
189#[derive(Debug, Clone, PartialEq, Eq)]
190#[non_exhaustive] // structs may have more fields added in the future.
191pub struct BasicAccount {
192    /// The user's unique Dropbox ID.
193    pub account_id: crate::types::users_common::AccountId,
194    /// Details of a user's name.
195    pub name: Name,
196    /// The user's email address. Do not rely on this without checking the `email_verified` field.
197    /// Even then, it's possible that the user has since lost access to their email.
198    pub email: String,
199    /// Whether the user has verified their email address.
200    pub email_verified: bool,
201    /// Whether the user has been disabled.
202    pub disabled: bool,
203    /// Whether this user is a teammate of the current user. If this account is the current user's
204    /// account, then this will be `true`.
205    pub is_teammate: bool,
206    /// URL for the photo representing the user, if one is set.
207    pub profile_photo_url: Option<String>,
208    /// The user's unique team member id. This field will only be present if the user is part of a
209    /// team and `is_teammate` is `true`.
210    pub team_member_id: Option<String>,
211}
212
213impl BasicAccount {
214    pub fn new(
215        account_id: crate::types::users_common::AccountId,
216        name: Name,
217        email: String,
218        email_verified: bool,
219        disabled: bool,
220        is_teammate: bool,
221    ) -> Self {
222        BasicAccount {
223            account_id,
224            name,
225            email,
226            email_verified,
227            disabled,
228            is_teammate,
229            profile_photo_url: None,
230            team_member_id: None,
231        }
232    }
233
234    pub fn with_profile_photo_url(mut self, value: String) -> Self {
235        self.profile_photo_url = Some(value);
236        self
237    }
238
239    pub fn with_team_member_id(mut self, value: String) -> Self {
240        self.team_member_id = Some(value);
241        self
242    }
243}
244
245const BASIC_ACCOUNT_FIELDS: &[&str] = &["account_id",
246                                        "name",
247                                        "email",
248                                        "email_verified",
249                                        "disabled",
250                                        "is_teammate",
251                                        "profile_photo_url",
252                                        "team_member_id"];
253impl BasicAccount {
254    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
255        map: V,
256    ) -> Result<BasicAccount, V::Error> {
257        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
258    }
259
260    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
261        mut map: V,
262        optional: bool,
263    ) -> Result<Option<BasicAccount>, V::Error> {
264        let mut field_account_id = None;
265        let mut field_name = None;
266        let mut field_email = None;
267        let mut field_email_verified = None;
268        let mut field_disabled = None;
269        let mut field_is_teammate = None;
270        let mut field_profile_photo_url = None;
271        let mut field_team_member_id = None;
272        let mut nothing = true;
273        while let Some(key) = map.next_key::<&str>()? {
274            nothing = false;
275            match key {
276                "account_id" => {
277                    if field_account_id.is_some() {
278                        return Err(::serde::de::Error::duplicate_field("account_id"));
279                    }
280                    field_account_id = Some(map.next_value()?);
281                }
282                "name" => {
283                    if field_name.is_some() {
284                        return Err(::serde::de::Error::duplicate_field("name"));
285                    }
286                    field_name = Some(map.next_value()?);
287                }
288                "email" => {
289                    if field_email.is_some() {
290                        return Err(::serde::de::Error::duplicate_field("email"));
291                    }
292                    field_email = Some(map.next_value()?);
293                }
294                "email_verified" => {
295                    if field_email_verified.is_some() {
296                        return Err(::serde::de::Error::duplicate_field("email_verified"));
297                    }
298                    field_email_verified = Some(map.next_value()?);
299                }
300                "disabled" => {
301                    if field_disabled.is_some() {
302                        return Err(::serde::de::Error::duplicate_field("disabled"));
303                    }
304                    field_disabled = Some(map.next_value()?);
305                }
306                "is_teammate" => {
307                    if field_is_teammate.is_some() {
308                        return Err(::serde::de::Error::duplicate_field("is_teammate"));
309                    }
310                    field_is_teammate = Some(map.next_value()?);
311                }
312                "profile_photo_url" => {
313                    if field_profile_photo_url.is_some() {
314                        return Err(::serde::de::Error::duplicate_field("profile_photo_url"));
315                    }
316                    field_profile_photo_url = Some(map.next_value()?);
317                }
318                "team_member_id" => {
319                    if field_team_member_id.is_some() {
320                        return Err(::serde::de::Error::duplicate_field("team_member_id"));
321                    }
322                    field_team_member_id = Some(map.next_value()?);
323                }
324                _ => {
325                    // unknown field allowed and ignored
326                    map.next_value::<::serde_json::Value>()?;
327                }
328            }
329        }
330        if optional && nothing {
331            return Ok(None);
332        }
333        let result = BasicAccount {
334            account_id: field_account_id.ok_or_else(|| ::serde::de::Error::missing_field("account_id"))?,
335            name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
336            email: field_email.ok_or_else(|| ::serde::de::Error::missing_field("email"))?,
337            email_verified: field_email_verified.ok_or_else(|| ::serde::de::Error::missing_field("email_verified"))?,
338            disabled: field_disabled.ok_or_else(|| ::serde::de::Error::missing_field("disabled"))?,
339            is_teammate: field_is_teammate.ok_or_else(|| ::serde::de::Error::missing_field("is_teammate"))?,
340            profile_photo_url: field_profile_photo_url.and_then(Option::flatten),
341            team_member_id: field_team_member_id.and_then(Option::flatten),
342        };
343        Ok(Some(result))
344    }
345
346    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
347        &self,
348        s: &mut S::SerializeStruct,
349    ) -> Result<(), S::Error> {
350        use serde::ser::SerializeStruct;
351        s.serialize_field("account_id", &self.account_id)?;
352        s.serialize_field("name", &self.name)?;
353        s.serialize_field("email", &self.email)?;
354        s.serialize_field("email_verified", &self.email_verified)?;
355        s.serialize_field("disabled", &self.disabled)?;
356        s.serialize_field("is_teammate", &self.is_teammate)?;
357        if let Some(val) = &self.profile_photo_url {
358            s.serialize_field("profile_photo_url", val)?;
359        }
360        if let Some(val) = &self.team_member_id {
361            s.serialize_field("team_member_id", val)?;
362        }
363        Ok(())
364    }
365}
366
367impl<'de> ::serde::de::Deserialize<'de> for BasicAccount {
368    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
369        // struct deserializer
370        use serde::de::{MapAccess, Visitor};
371        struct StructVisitor;
372        impl<'de> Visitor<'de> for StructVisitor {
373            type Value = BasicAccount;
374            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
375                f.write_str("a BasicAccount struct")
376            }
377            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
378                BasicAccount::internal_deserialize(map)
379            }
380        }
381        deserializer.deserialize_struct("BasicAccount", BASIC_ACCOUNT_FIELDS, StructVisitor)
382    }
383}
384
385impl ::serde::ser::Serialize for BasicAccount {
386    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
387        // struct serializer
388        use serde::ser::SerializeStruct;
389        let mut s = serializer.serialize_struct("BasicAccount", 8)?;
390        self.internal_serialize::<S>(&mut s)?;
391        s.end()
392    }
393}
394
395// struct extends Account
396impl From<BasicAccount> for Account {
397    fn from(subtype: BasicAccount) -> Self {
398        Self {
399            account_id: subtype.account_id,
400            name: subtype.name,
401            email: subtype.email,
402            email_verified: subtype.email_verified,
403            disabled: subtype.disabled,
404            profile_photo_url: subtype.profile_photo_url,
405        }
406    }
407}
408/// The value for [`UserFeature::DistinctMemberHome`].
409#[derive(Debug, Clone, PartialEq, Eq)]
410#[non_exhaustive] // variants may be added in the future
411pub enum DistinctMemberHomeValue {
412    /// When this value is True, the user have distinct home and root ns. When the value is False
413    /// the user's home ns and root ns are the same.
414    Enabled(bool),
415    /// Catch-all used for unrecognized values returned from the server. Encountering this value
416    /// typically indicates that this SDK version is out of date.
417    Other,
418}
419
420impl<'de> ::serde::de::Deserialize<'de> for DistinctMemberHomeValue {
421    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
422        // union deserializer
423        use serde::de::{self, MapAccess, Visitor};
424        struct EnumVisitor;
425        impl<'de> Visitor<'de> for EnumVisitor {
426            type Value = DistinctMemberHomeValue;
427            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
428                f.write_str("a DistinctMemberHomeValue structure")
429            }
430            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
431                let tag: &str = match map.next_key()? {
432                    Some(".tag") => map.next_value()?,
433                    _ => return Err(de::Error::missing_field(".tag"))
434                };
435                let value = match tag {
436                    "enabled" => {
437                        match map.next_key()? {
438                            Some("enabled") => DistinctMemberHomeValue::Enabled(map.next_value()?),
439                            None => return Err(de::Error::missing_field("enabled")),
440                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
441                        }
442                    }
443                    _ => DistinctMemberHomeValue::Other,
444                };
445                crate::eat_json_fields(&mut map)?;
446                Ok(value)
447            }
448        }
449        const VARIANTS: &[&str] = &["enabled",
450                                    "other"];
451        deserializer.deserialize_struct("DistinctMemberHomeValue", VARIANTS, EnumVisitor)
452    }
453}
454
455impl ::serde::ser::Serialize for DistinctMemberHomeValue {
456    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
457        // union serializer
458        use serde::ser::SerializeStruct;
459        match self {
460            DistinctMemberHomeValue::Enabled(x) => {
461                // primitive
462                let mut s = serializer.serialize_struct("DistinctMemberHomeValue", 2)?;
463                s.serialize_field(".tag", "enabled")?;
464                s.serialize_field("enabled", x)?;
465                s.end()
466            }
467            DistinctMemberHomeValue::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
468        }
469    }
470}
471
472/// The value for [`UserFeature::FileLocking`].
473#[derive(Debug, Clone, PartialEq, Eq)]
474#[non_exhaustive] // variants may be added in the future
475pub enum FileLockingValue {
476    /// When this value is True, the user can lock files in shared directories. When the value is
477    /// False the user can unlock the files they have locked or request to unlock files locked by
478    /// others.
479    Enabled(bool),
480    /// Catch-all used for unrecognized values returned from the server. Encountering this value
481    /// typically indicates that this SDK version is out of date.
482    Other,
483}
484
485impl<'de> ::serde::de::Deserialize<'de> for FileLockingValue {
486    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
487        // union deserializer
488        use serde::de::{self, MapAccess, Visitor};
489        struct EnumVisitor;
490        impl<'de> Visitor<'de> for EnumVisitor {
491            type Value = FileLockingValue;
492            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
493                f.write_str("a FileLockingValue structure")
494            }
495            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
496                let tag: &str = match map.next_key()? {
497                    Some(".tag") => map.next_value()?,
498                    _ => return Err(de::Error::missing_field(".tag"))
499                };
500                let value = match tag {
501                    "enabled" => {
502                        match map.next_key()? {
503                            Some("enabled") => FileLockingValue::Enabled(map.next_value()?),
504                            None => return Err(de::Error::missing_field("enabled")),
505                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
506                        }
507                    }
508                    _ => FileLockingValue::Other,
509                };
510                crate::eat_json_fields(&mut map)?;
511                Ok(value)
512            }
513        }
514        const VARIANTS: &[&str] = &["enabled",
515                                    "other"];
516        deserializer.deserialize_struct("FileLockingValue", VARIANTS, EnumVisitor)
517    }
518}
519
520impl ::serde::ser::Serialize for FileLockingValue {
521    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
522        // union serializer
523        use serde::ser::SerializeStruct;
524        match self {
525            FileLockingValue::Enabled(x) => {
526                // primitive
527                let mut s = serializer.serialize_struct("FileLockingValue", 2)?;
528                s.serialize_field(".tag", "enabled")?;
529                s.serialize_field("enabled", x)?;
530                s.end()
531            }
532            FileLockingValue::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
533        }
534    }
535}
536
537/// Detailed information about the current user's account.
538#[derive(Debug, Clone, PartialEq, Eq)]
539#[non_exhaustive] // structs may have more fields added in the future.
540pub struct FullAccount {
541    /// The user's unique Dropbox ID.
542    pub account_id: crate::types::users_common::AccountId,
543    /// Details of a user's name.
544    pub name: Name,
545    /// The user's email address. Do not rely on this without checking the `email_verified` field.
546    /// Even then, it's possible that the user has since lost access to their email.
547    pub email: String,
548    /// Whether the user has verified their email address.
549    pub email_verified: bool,
550    /// Whether the user has been disabled.
551    pub disabled: bool,
552    /// The language that the user specified. Locale tags will be [IETF language
553    /// tags](http://en.wikipedia.org/wiki/IETF_language_tag).
554    pub locale: String,
555    /// The user's [referral link](https://www.dropbox.com/referrals).
556    pub referral_link: String,
557    /// Whether the user has a personal and work account. If the current account is personal, then
558    /// `team` will always be `None`, but `is_paired` will indicate if a work account is linked.
559    pub is_paired: bool,
560    /// What type of account this user has.
561    pub account_type: crate::types::users_common::AccountType,
562    /// The root info for this account.
563    pub root_info: crate::types::common::RootInfo,
564    /// URL for the photo representing the user, if one is set.
565    pub profile_photo_url: Option<String>,
566    /// The user's two-letter country code, if available. Country codes are based on [ISO
567    /// 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1).
568    pub country: Option<String>,
569    /// If this account is a member of a team, information about that team.
570    pub team: Option<FullTeam>,
571    /// This account's unique team member id. This field will only be present if `team` is present.
572    pub team_member_id: Option<String>,
573}
574
575impl FullAccount {
576    pub fn new(
577        account_id: crate::types::users_common::AccountId,
578        name: Name,
579        email: String,
580        email_verified: bool,
581        disabled: bool,
582        locale: String,
583        referral_link: String,
584        is_paired: bool,
585        account_type: crate::types::users_common::AccountType,
586        root_info: crate::types::common::RootInfo,
587    ) -> Self {
588        FullAccount {
589            account_id,
590            name,
591            email,
592            email_verified,
593            disabled,
594            locale,
595            referral_link,
596            is_paired,
597            account_type,
598            root_info,
599            profile_photo_url: None,
600            country: None,
601            team: None,
602            team_member_id: None,
603        }
604    }
605
606    pub fn with_profile_photo_url(mut self, value: String) -> Self {
607        self.profile_photo_url = Some(value);
608        self
609    }
610
611    pub fn with_country(mut self, value: String) -> Self {
612        self.country = Some(value);
613        self
614    }
615
616    pub fn with_team(mut self, value: FullTeam) -> Self {
617        self.team = Some(value);
618        self
619    }
620
621    pub fn with_team_member_id(mut self, value: String) -> Self {
622        self.team_member_id = Some(value);
623        self
624    }
625}
626
627const FULL_ACCOUNT_FIELDS: &[&str] = &["account_id",
628                                       "name",
629                                       "email",
630                                       "email_verified",
631                                       "disabled",
632                                       "locale",
633                                       "referral_link",
634                                       "is_paired",
635                                       "account_type",
636                                       "root_info",
637                                       "profile_photo_url",
638                                       "country",
639                                       "team",
640                                       "team_member_id"];
641impl FullAccount {
642    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
643        map: V,
644    ) -> Result<FullAccount, V::Error> {
645        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
646    }
647
648    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
649        mut map: V,
650        optional: bool,
651    ) -> Result<Option<FullAccount>, V::Error> {
652        let mut field_account_id = None;
653        let mut field_name = None;
654        let mut field_email = None;
655        let mut field_email_verified = None;
656        let mut field_disabled = None;
657        let mut field_locale = None;
658        let mut field_referral_link = None;
659        let mut field_is_paired = None;
660        let mut field_account_type = None;
661        let mut field_root_info = None;
662        let mut field_profile_photo_url = None;
663        let mut field_country = None;
664        let mut field_team = None;
665        let mut field_team_member_id = None;
666        let mut nothing = true;
667        while let Some(key) = map.next_key::<&str>()? {
668            nothing = false;
669            match key {
670                "account_id" => {
671                    if field_account_id.is_some() {
672                        return Err(::serde::de::Error::duplicate_field("account_id"));
673                    }
674                    field_account_id = Some(map.next_value()?);
675                }
676                "name" => {
677                    if field_name.is_some() {
678                        return Err(::serde::de::Error::duplicate_field("name"));
679                    }
680                    field_name = Some(map.next_value()?);
681                }
682                "email" => {
683                    if field_email.is_some() {
684                        return Err(::serde::de::Error::duplicate_field("email"));
685                    }
686                    field_email = Some(map.next_value()?);
687                }
688                "email_verified" => {
689                    if field_email_verified.is_some() {
690                        return Err(::serde::de::Error::duplicate_field("email_verified"));
691                    }
692                    field_email_verified = Some(map.next_value()?);
693                }
694                "disabled" => {
695                    if field_disabled.is_some() {
696                        return Err(::serde::de::Error::duplicate_field("disabled"));
697                    }
698                    field_disabled = Some(map.next_value()?);
699                }
700                "locale" => {
701                    if field_locale.is_some() {
702                        return Err(::serde::de::Error::duplicate_field("locale"));
703                    }
704                    field_locale = Some(map.next_value()?);
705                }
706                "referral_link" => {
707                    if field_referral_link.is_some() {
708                        return Err(::serde::de::Error::duplicate_field("referral_link"));
709                    }
710                    field_referral_link = Some(map.next_value()?);
711                }
712                "is_paired" => {
713                    if field_is_paired.is_some() {
714                        return Err(::serde::de::Error::duplicate_field("is_paired"));
715                    }
716                    field_is_paired = Some(map.next_value()?);
717                }
718                "account_type" => {
719                    if field_account_type.is_some() {
720                        return Err(::serde::de::Error::duplicate_field("account_type"));
721                    }
722                    field_account_type = Some(map.next_value()?);
723                }
724                "root_info" => {
725                    if field_root_info.is_some() {
726                        return Err(::serde::de::Error::duplicate_field("root_info"));
727                    }
728                    field_root_info = Some(map.next_value()?);
729                }
730                "profile_photo_url" => {
731                    if field_profile_photo_url.is_some() {
732                        return Err(::serde::de::Error::duplicate_field("profile_photo_url"));
733                    }
734                    field_profile_photo_url = Some(map.next_value()?);
735                }
736                "country" => {
737                    if field_country.is_some() {
738                        return Err(::serde::de::Error::duplicate_field("country"));
739                    }
740                    field_country = Some(map.next_value()?);
741                }
742                "team" => {
743                    if field_team.is_some() {
744                        return Err(::serde::de::Error::duplicate_field("team"));
745                    }
746                    field_team = Some(map.next_value()?);
747                }
748                "team_member_id" => {
749                    if field_team_member_id.is_some() {
750                        return Err(::serde::de::Error::duplicate_field("team_member_id"));
751                    }
752                    field_team_member_id = Some(map.next_value()?);
753                }
754                _ => {
755                    // unknown field allowed and ignored
756                    map.next_value::<::serde_json::Value>()?;
757                }
758            }
759        }
760        if optional && nothing {
761            return Ok(None);
762        }
763        let result = FullAccount {
764            account_id: field_account_id.ok_or_else(|| ::serde::de::Error::missing_field("account_id"))?,
765            name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
766            email: field_email.ok_or_else(|| ::serde::de::Error::missing_field("email"))?,
767            email_verified: field_email_verified.ok_or_else(|| ::serde::de::Error::missing_field("email_verified"))?,
768            disabled: field_disabled.ok_or_else(|| ::serde::de::Error::missing_field("disabled"))?,
769            locale: field_locale.ok_or_else(|| ::serde::de::Error::missing_field("locale"))?,
770            referral_link: field_referral_link.ok_or_else(|| ::serde::de::Error::missing_field("referral_link"))?,
771            is_paired: field_is_paired.ok_or_else(|| ::serde::de::Error::missing_field("is_paired"))?,
772            account_type: field_account_type.ok_or_else(|| ::serde::de::Error::missing_field("account_type"))?,
773            root_info: field_root_info.ok_or_else(|| ::serde::de::Error::missing_field("root_info"))?,
774            profile_photo_url: field_profile_photo_url.and_then(Option::flatten),
775            country: field_country.and_then(Option::flatten),
776            team: field_team.and_then(Option::flatten),
777            team_member_id: field_team_member_id.and_then(Option::flatten),
778        };
779        Ok(Some(result))
780    }
781
782    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
783        &self,
784        s: &mut S::SerializeStruct,
785    ) -> Result<(), S::Error> {
786        use serde::ser::SerializeStruct;
787        s.serialize_field("account_id", &self.account_id)?;
788        s.serialize_field("name", &self.name)?;
789        s.serialize_field("email", &self.email)?;
790        s.serialize_field("email_verified", &self.email_verified)?;
791        s.serialize_field("disabled", &self.disabled)?;
792        s.serialize_field("locale", &self.locale)?;
793        s.serialize_field("referral_link", &self.referral_link)?;
794        s.serialize_field("is_paired", &self.is_paired)?;
795        s.serialize_field("account_type", &self.account_type)?;
796        s.serialize_field("root_info", &self.root_info)?;
797        if let Some(val) = &self.profile_photo_url {
798            s.serialize_field("profile_photo_url", val)?;
799        }
800        if let Some(val) = &self.country {
801            s.serialize_field("country", val)?;
802        }
803        if let Some(val) = &self.team {
804            s.serialize_field("team", val)?;
805        }
806        if let Some(val) = &self.team_member_id {
807            s.serialize_field("team_member_id", val)?;
808        }
809        Ok(())
810    }
811}
812
813impl<'de> ::serde::de::Deserialize<'de> for FullAccount {
814    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
815        // struct deserializer
816        use serde::de::{MapAccess, Visitor};
817        struct StructVisitor;
818        impl<'de> Visitor<'de> for StructVisitor {
819            type Value = FullAccount;
820            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
821                f.write_str("a FullAccount struct")
822            }
823            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
824                FullAccount::internal_deserialize(map)
825            }
826        }
827        deserializer.deserialize_struct("FullAccount", FULL_ACCOUNT_FIELDS, StructVisitor)
828    }
829}
830
831impl ::serde::ser::Serialize for FullAccount {
832    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
833        // struct serializer
834        use serde::ser::SerializeStruct;
835        let mut s = serializer.serialize_struct("FullAccount", 14)?;
836        self.internal_serialize::<S>(&mut s)?;
837        s.end()
838    }
839}
840
841// struct extends Account
842impl From<FullAccount> for Account {
843    fn from(subtype: FullAccount) -> Self {
844        Self {
845            account_id: subtype.account_id,
846            name: subtype.name,
847            email: subtype.email,
848            email_verified: subtype.email_verified,
849            disabled: subtype.disabled,
850            profile_photo_url: subtype.profile_photo_url,
851        }
852    }
853}
854/// Detailed information about a team.
855#[derive(Debug, Clone, PartialEq, Eq)]
856#[non_exhaustive] // structs may have more fields added in the future.
857pub struct FullTeam {
858    /// The team's unique ID.
859    pub id: String,
860    /// The name of the team.
861    pub name: String,
862    /// Team policies governing sharing.
863    pub sharing_policies: crate::types::team_policies::TeamSharingPolicies,
864    /// Team policy governing the use of the Office Add-In.
865    pub office_addin_policy: crate::types::team_policies::OfficeAddInPolicy,
866    /// Team policy governing whether members can edit team folders at the top level of the team
867    /// space.
868    pub top_level_content_policy: crate::types::team_policies::TopLevelContentPolicy,
869}
870
871impl FullTeam {
872    pub fn new(
873        id: String,
874        name: String,
875        sharing_policies: crate::types::team_policies::TeamSharingPolicies,
876        office_addin_policy: crate::types::team_policies::OfficeAddInPolicy,
877        top_level_content_policy: crate::types::team_policies::TopLevelContentPolicy,
878    ) -> Self {
879        FullTeam {
880            id,
881            name,
882            sharing_policies,
883            office_addin_policy,
884            top_level_content_policy,
885        }
886    }
887}
888
889const FULL_TEAM_FIELDS: &[&str] = &["id",
890                                    "name",
891                                    "sharing_policies",
892                                    "office_addin_policy",
893                                    "top_level_content_policy"];
894impl FullTeam {
895    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
896        map: V,
897    ) -> Result<FullTeam, V::Error> {
898        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
899    }
900
901    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
902        mut map: V,
903        optional: bool,
904    ) -> Result<Option<FullTeam>, V::Error> {
905        let mut field_id = None;
906        let mut field_name = None;
907        let mut field_sharing_policies = None;
908        let mut field_office_addin_policy = None;
909        let mut field_top_level_content_policy = None;
910        let mut nothing = true;
911        while let Some(key) = map.next_key::<&str>()? {
912            nothing = false;
913            match key {
914                "id" => {
915                    if field_id.is_some() {
916                        return Err(::serde::de::Error::duplicate_field("id"));
917                    }
918                    field_id = Some(map.next_value()?);
919                }
920                "name" => {
921                    if field_name.is_some() {
922                        return Err(::serde::de::Error::duplicate_field("name"));
923                    }
924                    field_name = Some(map.next_value()?);
925                }
926                "sharing_policies" => {
927                    if field_sharing_policies.is_some() {
928                        return Err(::serde::de::Error::duplicate_field("sharing_policies"));
929                    }
930                    field_sharing_policies = Some(map.next_value()?);
931                }
932                "office_addin_policy" => {
933                    if field_office_addin_policy.is_some() {
934                        return Err(::serde::de::Error::duplicate_field("office_addin_policy"));
935                    }
936                    field_office_addin_policy = Some(map.next_value()?);
937                }
938                "top_level_content_policy" => {
939                    if field_top_level_content_policy.is_some() {
940                        return Err(::serde::de::Error::duplicate_field("top_level_content_policy"));
941                    }
942                    field_top_level_content_policy = Some(map.next_value()?);
943                }
944                _ => {
945                    // unknown field allowed and ignored
946                    map.next_value::<::serde_json::Value>()?;
947                }
948            }
949        }
950        if optional && nothing {
951            return Ok(None);
952        }
953        let result = FullTeam {
954            id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
955            name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
956            sharing_policies: field_sharing_policies.ok_or_else(|| ::serde::de::Error::missing_field("sharing_policies"))?,
957            office_addin_policy: field_office_addin_policy.ok_or_else(|| ::serde::de::Error::missing_field("office_addin_policy"))?,
958            top_level_content_policy: field_top_level_content_policy.ok_or_else(|| ::serde::de::Error::missing_field("top_level_content_policy"))?,
959        };
960        Ok(Some(result))
961    }
962
963    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
964        &self,
965        s: &mut S::SerializeStruct,
966    ) -> Result<(), S::Error> {
967        use serde::ser::SerializeStruct;
968        s.serialize_field("id", &self.id)?;
969        s.serialize_field("name", &self.name)?;
970        s.serialize_field("sharing_policies", &self.sharing_policies)?;
971        s.serialize_field("office_addin_policy", &self.office_addin_policy)?;
972        s.serialize_field("top_level_content_policy", &self.top_level_content_policy)?;
973        Ok(())
974    }
975}
976
977impl<'de> ::serde::de::Deserialize<'de> for FullTeam {
978    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
979        // struct deserializer
980        use serde::de::{MapAccess, Visitor};
981        struct StructVisitor;
982        impl<'de> Visitor<'de> for StructVisitor {
983            type Value = FullTeam;
984            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
985                f.write_str("a FullTeam struct")
986            }
987            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
988                FullTeam::internal_deserialize(map)
989            }
990        }
991        deserializer.deserialize_struct("FullTeam", FULL_TEAM_FIELDS, StructVisitor)
992    }
993}
994
995impl ::serde::ser::Serialize for FullTeam {
996    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
997        // struct serializer
998        use serde::ser::SerializeStruct;
999        let mut s = serializer.serialize_struct("FullTeam", 5)?;
1000        self.internal_serialize::<S>(&mut s)?;
1001        s.end()
1002    }
1003}
1004
1005// struct extends Team
1006impl From<FullTeam> for Team {
1007    fn from(subtype: FullTeam) -> Self {
1008        Self {
1009            id: subtype.id,
1010            name: subtype.name,
1011        }
1012    }
1013}
1014#[derive(Debug, Clone, PartialEq, Eq)]
1015#[non_exhaustive] // structs may have more fields added in the future.
1016pub struct GetAccountArg {
1017    /// A user's account identifier.
1018    pub account_id: crate::types::users_common::AccountId,
1019}
1020
1021impl GetAccountArg {
1022    pub fn new(account_id: crate::types::users_common::AccountId) -> Self {
1023        GetAccountArg {
1024            account_id,
1025        }
1026    }
1027}
1028
1029const GET_ACCOUNT_ARG_FIELDS: &[&str] = &["account_id"];
1030impl GetAccountArg {
1031    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1032        map: V,
1033    ) -> Result<GetAccountArg, V::Error> {
1034        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1035    }
1036
1037    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1038        mut map: V,
1039        optional: bool,
1040    ) -> Result<Option<GetAccountArg>, V::Error> {
1041        let mut field_account_id = None;
1042        let mut nothing = true;
1043        while let Some(key) = map.next_key::<&str>()? {
1044            nothing = false;
1045            match key {
1046                "account_id" => {
1047                    if field_account_id.is_some() {
1048                        return Err(::serde::de::Error::duplicate_field("account_id"));
1049                    }
1050                    field_account_id = Some(map.next_value()?);
1051                }
1052                _ => {
1053                    // unknown field allowed and ignored
1054                    map.next_value::<::serde_json::Value>()?;
1055                }
1056            }
1057        }
1058        if optional && nothing {
1059            return Ok(None);
1060        }
1061        let result = GetAccountArg {
1062            account_id: field_account_id.ok_or_else(|| ::serde::de::Error::missing_field("account_id"))?,
1063        };
1064        Ok(Some(result))
1065    }
1066
1067    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1068        &self,
1069        s: &mut S::SerializeStruct,
1070    ) -> Result<(), S::Error> {
1071        use serde::ser::SerializeStruct;
1072        s.serialize_field("account_id", &self.account_id)?;
1073        Ok(())
1074    }
1075}
1076
1077impl<'de> ::serde::de::Deserialize<'de> for GetAccountArg {
1078    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1079        // struct deserializer
1080        use serde::de::{MapAccess, Visitor};
1081        struct StructVisitor;
1082        impl<'de> Visitor<'de> for StructVisitor {
1083            type Value = GetAccountArg;
1084            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1085                f.write_str("a GetAccountArg struct")
1086            }
1087            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1088                GetAccountArg::internal_deserialize(map)
1089            }
1090        }
1091        deserializer.deserialize_struct("GetAccountArg", GET_ACCOUNT_ARG_FIELDS, StructVisitor)
1092    }
1093}
1094
1095impl ::serde::ser::Serialize for GetAccountArg {
1096    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1097        // struct serializer
1098        use serde::ser::SerializeStruct;
1099        let mut s = serializer.serialize_struct("GetAccountArg", 1)?;
1100        self.internal_serialize::<S>(&mut s)?;
1101        s.end()
1102    }
1103}
1104
1105#[derive(Debug, Clone, PartialEq, Eq)]
1106#[non_exhaustive] // structs may have more fields added in the future.
1107pub struct GetAccountBatchArg {
1108    /// List of user account identifiers.  Should not contain any duplicate account IDs.
1109    pub account_ids: Vec<crate::types::users_common::AccountId>,
1110}
1111
1112impl GetAccountBatchArg {
1113    pub fn new(account_ids: Vec<crate::types::users_common::AccountId>) -> Self {
1114        GetAccountBatchArg {
1115            account_ids,
1116        }
1117    }
1118}
1119
1120const GET_ACCOUNT_BATCH_ARG_FIELDS: &[&str] = &["account_ids"];
1121impl GetAccountBatchArg {
1122    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1123        map: V,
1124    ) -> Result<GetAccountBatchArg, V::Error> {
1125        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1126    }
1127
1128    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1129        mut map: V,
1130        optional: bool,
1131    ) -> Result<Option<GetAccountBatchArg>, V::Error> {
1132        let mut field_account_ids = None;
1133        let mut nothing = true;
1134        while let Some(key) = map.next_key::<&str>()? {
1135            nothing = false;
1136            match key {
1137                "account_ids" => {
1138                    if field_account_ids.is_some() {
1139                        return Err(::serde::de::Error::duplicate_field("account_ids"));
1140                    }
1141                    field_account_ids = Some(map.next_value()?);
1142                }
1143                _ => {
1144                    // unknown field allowed and ignored
1145                    map.next_value::<::serde_json::Value>()?;
1146                }
1147            }
1148        }
1149        if optional && nothing {
1150            return Ok(None);
1151        }
1152        let result = GetAccountBatchArg {
1153            account_ids: field_account_ids.ok_or_else(|| ::serde::de::Error::missing_field("account_ids"))?,
1154        };
1155        Ok(Some(result))
1156    }
1157
1158    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1159        &self,
1160        s: &mut S::SerializeStruct,
1161    ) -> Result<(), S::Error> {
1162        use serde::ser::SerializeStruct;
1163        s.serialize_field("account_ids", &self.account_ids)?;
1164        Ok(())
1165    }
1166}
1167
1168impl<'de> ::serde::de::Deserialize<'de> for GetAccountBatchArg {
1169    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1170        // struct deserializer
1171        use serde::de::{MapAccess, Visitor};
1172        struct StructVisitor;
1173        impl<'de> Visitor<'de> for StructVisitor {
1174            type Value = GetAccountBatchArg;
1175            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1176                f.write_str("a GetAccountBatchArg struct")
1177            }
1178            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1179                GetAccountBatchArg::internal_deserialize(map)
1180            }
1181        }
1182        deserializer.deserialize_struct("GetAccountBatchArg", GET_ACCOUNT_BATCH_ARG_FIELDS, StructVisitor)
1183    }
1184}
1185
1186impl ::serde::ser::Serialize for GetAccountBatchArg {
1187    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1188        // struct serializer
1189        use serde::ser::SerializeStruct;
1190        let mut s = serializer.serialize_struct("GetAccountBatchArg", 1)?;
1191        self.internal_serialize::<S>(&mut s)?;
1192        s.end()
1193    }
1194}
1195
1196#[derive(Debug, Clone, PartialEq, Eq)]
1197#[non_exhaustive] // variants may be added in the future
1198pub enum GetAccountBatchError {
1199    /// The value is an account ID specified in
1200    /// [`GetAccountBatchArg::account_ids`](GetAccountBatchArg) that does not exist.
1201    NoAccount(crate::types::users_common::AccountId),
1202    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1203    /// typically indicates that this SDK version is out of date.
1204    Other,
1205}
1206
1207impl<'de> ::serde::de::Deserialize<'de> for GetAccountBatchError {
1208    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1209        // union deserializer
1210        use serde::de::{self, MapAccess, Visitor};
1211        struct EnumVisitor;
1212        impl<'de> Visitor<'de> for EnumVisitor {
1213            type Value = GetAccountBatchError;
1214            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1215                f.write_str("a GetAccountBatchError structure")
1216            }
1217            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1218                let tag: &str = match map.next_key()? {
1219                    Some(".tag") => map.next_value()?,
1220                    _ => return Err(de::Error::missing_field(".tag"))
1221                };
1222                let value = match tag {
1223                    "no_account" => {
1224                        match map.next_key()? {
1225                            Some("no_account") => GetAccountBatchError::NoAccount(map.next_value()?),
1226                            None => return Err(de::Error::missing_field("no_account")),
1227                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1228                        }
1229                    }
1230                    _ => GetAccountBatchError::Other,
1231                };
1232                crate::eat_json_fields(&mut map)?;
1233                Ok(value)
1234            }
1235        }
1236        const VARIANTS: &[&str] = &["no_account",
1237                                    "other"];
1238        deserializer.deserialize_struct("GetAccountBatchError", VARIANTS, EnumVisitor)
1239    }
1240}
1241
1242impl ::serde::ser::Serialize for GetAccountBatchError {
1243    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1244        // union serializer
1245        use serde::ser::SerializeStruct;
1246        match self {
1247            GetAccountBatchError::NoAccount(x) => {
1248                // primitive
1249                let mut s = serializer.serialize_struct("GetAccountBatchError", 2)?;
1250                s.serialize_field(".tag", "no_account")?;
1251                s.serialize_field("no_account", x)?;
1252                s.end()
1253            }
1254            GetAccountBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1255        }
1256    }
1257}
1258
1259impl ::std::error::Error for GetAccountBatchError {
1260}
1261
1262impl ::std::fmt::Display for GetAccountBatchError {
1263    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1264        match self {
1265            GetAccountBatchError::NoAccount(inner) => write!(f, "no_account: {:?}", inner),
1266            _ => write!(f, "{:?}", *self),
1267        }
1268    }
1269}
1270
1271#[derive(Debug, Clone, PartialEq, Eq)]
1272#[non_exhaustive] // variants may be added in the future
1273pub enum GetAccountError {
1274    /// The specified [`GetAccountArg::account_id`](GetAccountArg) does not exist.
1275    NoAccount,
1276    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1277    /// typically indicates that this SDK version is out of date.
1278    Other,
1279}
1280
1281impl<'de> ::serde::de::Deserialize<'de> for GetAccountError {
1282    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1283        // union deserializer
1284        use serde::de::{self, MapAccess, Visitor};
1285        struct EnumVisitor;
1286        impl<'de> Visitor<'de> for EnumVisitor {
1287            type Value = GetAccountError;
1288            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1289                f.write_str("a GetAccountError structure")
1290            }
1291            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1292                let tag: &str = match map.next_key()? {
1293                    Some(".tag") => map.next_value()?,
1294                    _ => return Err(de::Error::missing_field(".tag"))
1295                };
1296                let value = match tag {
1297                    "no_account" => GetAccountError::NoAccount,
1298                    _ => GetAccountError::Other,
1299                };
1300                crate::eat_json_fields(&mut map)?;
1301                Ok(value)
1302            }
1303        }
1304        const VARIANTS: &[&str] = &["no_account",
1305                                    "other"];
1306        deserializer.deserialize_struct("GetAccountError", VARIANTS, EnumVisitor)
1307    }
1308}
1309
1310impl ::serde::ser::Serialize for GetAccountError {
1311    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1312        // union serializer
1313        use serde::ser::SerializeStruct;
1314        match self {
1315            GetAccountError::NoAccount => {
1316                // unit
1317                let mut s = serializer.serialize_struct("GetAccountError", 1)?;
1318                s.serialize_field(".tag", "no_account")?;
1319                s.end()
1320            }
1321            GetAccountError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1322        }
1323    }
1324}
1325
1326impl ::std::error::Error for GetAccountError {
1327}
1328
1329impl ::std::fmt::Display for GetAccountError {
1330    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1331        write!(f, "{:?}", *self)
1332    }
1333}
1334
1335#[derive(Debug, Clone, PartialEq, Eq)]
1336#[non_exhaustive] // structs may have more fields added in the future.
1337pub struct IndividualSpaceAllocation {
1338    /// The total space allocated to the user's account (bytes).
1339    pub allocated: u64,
1340}
1341
1342impl IndividualSpaceAllocation {
1343    pub fn new(allocated: u64) -> Self {
1344        IndividualSpaceAllocation {
1345            allocated,
1346        }
1347    }
1348}
1349
1350const INDIVIDUAL_SPACE_ALLOCATION_FIELDS: &[&str] = &["allocated"];
1351impl IndividualSpaceAllocation {
1352    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1353        map: V,
1354    ) -> Result<IndividualSpaceAllocation, V::Error> {
1355        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1356    }
1357
1358    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1359        mut map: V,
1360        optional: bool,
1361    ) -> Result<Option<IndividualSpaceAllocation>, V::Error> {
1362        let mut field_allocated = None;
1363        let mut nothing = true;
1364        while let Some(key) = map.next_key::<&str>()? {
1365            nothing = false;
1366            match key {
1367                "allocated" => {
1368                    if field_allocated.is_some() {
1369                        return Err(::serde::de::Error::duplicate_field("allocated"));
1370                    }
1371                    field_allocated = Some(map.next_value()?);
1372                }
1373                _ => {
1374                    // unknown field allowed and ignored
1375                    map.next_value::<::serde_json::Value>()?;
1376                }
1377            }
1378        }
1379        if optional && nothing {
1380            return Ok(None);
1381        }
1382        let result = IndividualSpaceAllocation {
1383            allocated: field_allocated.ok_or_else(|| ::serde::de::Error::missing_field("allocated"))?,
1384        };
1385        Ok(Some(result))
1386    }
1387
1388    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1389        &self,
1390        s: &mut S::SerializeStruct,
1391    ) -> Result<(), S::Error> {
1392        use serde::ser::SerializeStruct;
1393        s.serialize_field("allocated", &self.allocated)?;
1394        Ok(())
1395    }
1396}
1397
1398impl<'de> ::serde::de::Deserialize<'de> for IndividualSpaceAllocation {
1399    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1400        // struct deserializer
1401        use serde::de::{MapAccess, Visitor};
1402        struct StructVisitor;
1403        impl<'de> Visitor<'de> for StructVisitor {
1404            type Value = IndividualSpaceAllocation;
1405            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1406                f.write_str("a IndividualSpaceAllocation struct")
1407            }
1408            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1409                IndividualSpaceAllocation::internal_deserialize(map)
1410            }
1411        }
1412        deserializer.deserialize_struct("IndividualSpaceAllocation", INDIVIDUAL_SPACE_ALLOCATION_FIELDS, StructVisitor)
1413    }
1414}
1415
1416impl ::serde::ser::Serialize for IndividualSpaceAllocation {
1417    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1418        // struct serializer
1419        use serde::ser::SerializeStruct;
1420        let mut s = serializer.serialize_struct("IndividualSpaceAllocation", 1)?;
1421        self.internal_serialize::<S>(&mut s)?;
1422        s.end()
1423    }
1424}
1425
1426/// Representations for a person's name to assist with internationalization.
1427#[derive(Debug, Clone, PartialEq, Eq)]
1428#[non_exhaustive] // structs may have more fields added in the future.
1429pub struct Name {
1430    /// Also known as a first name.
1431    pub given_name: String,
1432    /// Also known as a last name or family name.
1433    pub surname: String,
1434    /// Locale-dependent name. In the US, a person's familiar name is their `given_name`, but
1435    /// elsewhere, it could be any combination of a person's `given_name` and `surname`.
1436    pub familiar_name: String,
1437    /// A name that can be used directly to represent the name of a user's Dropbox account.
1438    pub display_name: String,
1439    /// An abbreviated form of the person's name. Their initials in most locales.
1440    pub abbreviated_name: String,
1441}
1442
1443impl Name {
1444    pub fn new(
1445        given_name: String,
1446        surname: String,
1447        familiar_name: String,
1448        display_name: String,
1449        abbreviated_name: String,
1450    ) -> Self {
1451        Name {
1452            given_name,
1453            surname,
1454            familiar_name,
1455            display_name,
1456            abbreviated_name,
1457        }
1458    }
1459}
1460
1461const NAME_FIELDS: &[&str] = &["given_name",
1462                               "surname",
1463                               "familiar_name",
1464                               "display_name",
1465                               "abbreviated_name"];
1466impl Name {
1467    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1468        map: V,
1469    ) -> Result<Name, V::Error> {
1470        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1471    }
1472
1473    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1474        mut map: V,
1475        optional: bool,
1476    ) -> Result<Option<Name>, V::Error> {
1477        let mut field_given_name = None;
1478        let mut field_surname = None;
1479        let mut field_familiar_name = None;
1480        let mut field_display_name = None;
1481        let mut field_abbreviated_name = None;
1482        let mut nothing = true;
1483        while let Some(key) = map.next_key::<&str>()? {
1484            nothing = false;
1485            match key {
1486                "given_name" => {
1487                    if field_given_name.is_some() {
1488                        return Err(::serde::de::Error::duplicate_field("given_name"));
1489                    }
1490                    field_given_name = Some(map.next_value()?);
1491                }
1492                "surname" => {
1493                    if field_surname.is_some() {
1494                        return Err(::serde::de::Error::duplicate_field("surname"));
1495                    }
1496                    field_surname = Some(map.next_value()?);
1497                }
1498                "familiar_name" => {
1499                    if field_familiar_name.is_some() {
1500                        return Err(::serde::de::Error::duplicate_field("familiar_name"));
1501                    }
1502                    field_familiar_name = Some(map.next_value()?);
1503                }
1504                "display_name" => {
1505                    if field_display_name.is_some() {
1506                        return Err(::serde::de::Error::duplicate_field("display_name"));
1507                    }
1508                    field_display_name = Some(map.next_value()?);
1509                }
1510                "abbreviated_name" => {
1511                    if field_abbreviated_name.is_some() {
1512                        return Err(::serde::de::Error::duplicate_field("abbreviated_name"));
1513                    }
1514                    field_abbreviated_name = Some(map.next_value()?);
1515                }
1516                _ => {
1517                    // unknown field allowed and ignored
1518                    map.next_value::<::serde_json::Value>()?;
1519                }
1520            }
1521        }
1522        if optional && nothing {
1523            return Ok(None);
1524        }
1525        let result = Name {
1526            given_name: field_given_name.ok_or_else(|| ::serde::de::Error::missing_field("given_name"))?,
1527            surname: field_surname.ok_or_else(|| ::serde::de::Error::missing_field("surname"))?,
1528            familiar_name: field_familiar_name.ok_or_else(|| ::serde::de::Error::missing_field("familiar_name"))?,
1529            display_name: field_display_name.ok_or_else(|| ::serde::de::Error::missing_field("display_name"))?,
1530            abbreviated_name: field_abbreviated_name.ok_or_else(|| ::serde::de::Error::missing_field("abbreviated_name"))?,
1531        };
1532        Ok(Some(result))
1533    }
1534
1535    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1536        &self,
1537        s: &mut S::SerializeStruct,
1538    ) -> Result<(), S::Error> {
1539        use serde::ser::SerializeStruct;
1540        s.serialize_field("given_name", &self.given_name)?;
1541        s.serialize_field("surname", &self.surname)?;
1542        s.serialize_field("familiar_name", &self.familiar_name)?;
1543        s.serialize_field("display_name", &self.display_name)?;
1544        s.serialize_field("abbreviated_name", &self.abbreviated_name)?;
1545        Ok(())
1546    }
1547}
1548
1549impl<'de> ::serde::de::Deserialize<'de> for Name {
1550    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1551        // struct deserializer
1552        use serde::de::{MapAccess, Visitor};
1553        struct StructVisitor;
1554        impl<'de> Visitor<'de> for StructVisitor {
1555            type Value = Name;
1556            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1557                f.write_str("a Name struct")
1558            }
1559            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1560                Name::internal_deserialize(map)
1561            }
1562        }
1563        deserializer.deserialize_struct("Name", NAME_FIELDS, StructVisitor)
1564    }
1565}
1566
1567impl ::serde::ser::Serialize for Name {
1568    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1569        // struct serializer
1570        use serde::ser::SerializeStruct;
1571        let mut s = serializer.serialize_struct("Name", 5)?;
1572        self.internal_serialize::<S>(&mut s)?;
1573        s.end()
1574    }
1575}
1576
1577/// The value for [`UserFeature::PaperAsFiles`].
1578#[derive(Debug, Clone, PartialEq, Eq)]
1579#[non_exhaustive] // variants may be added in the future
1580pub enum PaperAsFilesValue {
1581    /// When this value is true, the user's Paper docs are accessible in Dropbox with the .paper
1582    /// extension and must be accessed via the /files endpoints.  When this value is false, the
1583    /// user's Paper docs are stored separate from Dropbox files and folders and should be accessed
1584    /// via the /paper endpoints.
1585    Enabled(bool),
1586    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1587    /// typically indicates that this SDK version is out of date.
1588    Other,
1589}
1590
1591impl<'de> ::serde::de::Deserialize<'de> for PaperAsFilesValue {
1592    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1593        // union deserializer
1594        use serde::de::{self, MapAccess, Visitor};
1595        struct EnumVisitor;
1596        impl<'de> Visitor<'de> for EnumVisitor {
1597            type Value = PaperAsFilesValue;
1598            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1599                f.write_str("a PaperAsFilesValue structure")
1600            }
1601            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1602                let tag: &str = match map.next_key()? {
1603                    Some(".tag") => map.next_value()?,
1604                    _ => return Err(de::Error::missing_field(".tag"))
1605                };
1606                let value = match tag {
1607                    "enabled" => {
1608                        match map.next_key()? {
1609                            Some("enabled") => PaperAsFilesValue::Enabled(map.next_value()?),
1610                            None => return Err(de::Error::missing_field("enabled")),
1611                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1612                        }
1613                    }
1614                    _ => PaperAsFilesValue::Other,
1615                };
1616                crate::eat_json_fields(&mut map)?;
1617                Ok(value)
1618            }
1619        }
1620        const VARIANTS: &[&str] = &["enabled",
1621                                    "other"];
1622        deserializer.deserialize_struct("PaperAsFilesValue", VARIANTS, EnumVisitor)
1623    }
1624}
1625
1626impl ::serde::ser::Serialize for PaperAsFilesValue {
1627    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1628        // union serializer
1629        use serde::ser::SerializeStruct;
1630        match self {
1631            PaperAsFilesValue::Enabled(x) => {
1632                // primitive
1633                let mut s = serializer.serialize_struct("PaperAsFilesValue", 2)?;
1634                s.serialize_field(".tag", "enabled")?;
1635                s.serialize_field("enabled", x)?;
1636                s.end()
1637            }
1638            PaperAsFilesValue::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1639        }
1640    }
1641}
1642
1643/// Space is allocated differently based on the type of account.
1644#[derive(Debug, Clone, PartialEq, Eq)]
1645#[non_exhaustive] // variants may be added in the future
1646pub enum SpaceAllocation {
1647    /// The user's space allocation applies only to their individual account.
1648    Individual(IndividualSpaceAllocation),
1649    /// The user shares space with other members of their team.
1650    Team(TeamSpaceAllocation),
1651    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1652    /// typically indicates that this SDK version is out of date.
1653    Other,
1654}
1655
1656impl<'de> ::serde::de::Deserialize<'de> for SpaceAllocation {
1657    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1658        // union deserializer
1659        use serde::de::{self, MapAccess, Visitor};
1660        struct EnumVisitor;
1661        impl<'de> Visitor<'de> for EnumVisitor {
1662            type Value = SpaceAllocation;
1663            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1664                f.write_str("a SpaceAllocation structure")
1665            }
1666            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1667                let tag: &str = match map.next_key()? {
1668                    Some(".tag") => map.next_value()?,
1669                    _ => return Err(de::Error::missing_field(".tag"))
1670                };
1671                let value = match tag {
1672                    "individual" => SpaceAllocation::Individual(IndividualSpaceAllocation::internal_deserialize(&mut map)?),
1673                    "team" => SpaceAllocation::Team(TeamSpaceAllocation::internal_deserialize(&mut map)?),
1674                    _ => SpaceAllocation::Other,
1675                };
1676                crate::eat_json_fields(&mut map)?;
1677                Ok(value)
1678            }
1679        }
1680        const VARIANTS: &[&str] = &["individual",
1681                                    "team",
1682                                    "other"];
1683        deserializer.deserialize_struct("SpaceAllocation", VARIANTS, EnumVisitor)
1684    }
1685}
1686
1687impl ::serde::ser::Serialize for SpaceAllocation {
1688    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1689        // union serializer
1690        use serde::ser::SerializeStruct;
1691        match self {
1692            SpaceAllocation::Individual(x) => {
1693                // struct
1694                let mut s = serializer.serialize_struct("SpaceAllocation", 2)?;
1695                s.serialize_field(".tag", "individual")?;
1696                x.internal_serialize::<S>(&mut s)?;
1697                s.end()
1698            }
1699            SpaceAllocation::Team(x) => {
1700                // struct
1701                let mut s = serializer.serialize_struct("SpaceAllocation", 6)?;
1702                s.serialize_field(".tag", "team")?;
1703                x.internal_serialize::<S>(&mut s)?;
1704                s.end()
1705            }
1706            SpaceAllocation::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1707        }
1708    }
1709}
1710
1711/// Information about a user's space usage and quota.
1712#[derive(Debug, Clone, PartialEq, Eq)]
1713#[non_exhaustive] // structs may have more fields added in the future.
1714pub struct SpaceUsage {
1715    /// The user's total space usage (bytes).
1716    pub used: u64,
1717    /// The user's space allocation.
1718    pub allocation: SpaceAllocation,
1719}
1720
1721impl SpaceUsage {
1722    pub fn new(used: u64, allocation: SpaceAllocation) -> Self {
1723        SpaceUsage {
1724            used,
1725            allocation,
1726        }
1727    }
1728}
1729
1730const SPACE_USAGE_FIELDS: &[&str] = &["used",
1731                                      "allocation"];
1732impl SpaceUsage {
1733    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1734        map: V,
1735    ) -> Result<SpaceUsage, V::Error> {
1736        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1737    }
1738
1739    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1740        mut map: V,
1741        optional: bool,
1742    ) -> Result<Option<SpaceUsage>, V::Error> {
1743        let mut field_used = None;
1744        let mut field_allocation = None;
1745        let mut nothing = true;
1746        while let Some(key) = map.next_key::<&str>()? {
1747            nothing = false;
1748            match key {
1749                "used" => {
1750                    if field_used.is_some() {
1751                        return Err(::serde::de::Error::duplicate_field("used"));
1752                    }
1753                    field_used = Some(map.next_value()?);
1754                }
1755                "allocation" => {
1756                    if field_allocation.is_some() {
1757                        return Err(::serde::de::Error::duplicate_field("allocation"));
1758                    }
1759                    field_allocation = Some(map.next_value()?);
1760                }
1761                _ => {
1762                    // unknown field allowed and ignored
1763                    map.next_value::<::serde_json::Value>()?;
1764                }
1765            }
1766        }
1767        if optional && nothing {
1768            return Ok(None);
1769        }
1770        let result = SpaceUsage {
1771            used: field_used.ok_or_else(|| ::serde::de::Error::missing_field("used"))?,
1772            allocation: field_allocation.ok_or_else(|| ::serde::de::Error::missing_field("allocation"))?,
1773        };
1774        Ok(Some(result))
1775    }
1776
1777    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1778        &self,
1779        s: &mut S::SerializeStruct,
1780    ) -> Result<(), S::Error> {
1781        use serde::ser::SerializeStruct;
1782        s.serialize_field("used", &self.used)?;
1783        s.serialize_field("allocation", &self.allocation)?;
1784        Ok(())
1785    }
1786}
1787
1788impl<'de> ::serde::de::Deserialize<'de> for SpaceUsage {
1789    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1790        // struct deserializer
1791        use serde::de::{MapAccess, Visitor};
1792        struct StructVisitor;
1793        impl<'de> Visitor<'de> for StructVisitor {
1794            type Value = SpaceUsage;
1795            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1796                f.write_str("a SpaceUsage struct")
1797            }
1798            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1799                SpaceUsage::internal_deserialize(map)
1800            }
1801        }
1802        deserializer.deserialize_struct("SpaceUsage", SPACE_USAGE_FIELDS, StructVisitor)
1803    }
1804}
1805
1806impl ::serde::ser::Serialize for SpaceUsage {
1807    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1808        // struct serializer
1809        use serde::ser::SerializeStruct;
1810        let mut s = serializer.serialize_struct("SpaceUsage", 2)?;
1811        self.internal_serialize::<S>(&mut s)?;
1812        s.end()
1813    }
1814}
1815
1816/// Information about a team.
1817#[derive(Debug, Clone, PartialEq, Eq)]
1818#[non_exhaustive] // structs may have more fields added in the future.
1819pub struct Team {
1820    /// The team's unique ID.
1821    pub id: String,
1822    /// The name of the team.
1823    pub name: String,
1824}
1825
1826impl Team {
1827    pub fn new(id: String, name: String) -> Self {
1828        Team {
1829            id,
1830            name,
1831        }
1832    }
1833}
1834
1835const TEAM_FIELDS: &[&str] = &["id",
1836                               "name"];
1837impl Team {
1838    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1839        map: V,
1840    ) -> Result<Team, V::Error> {
1841        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1842    }
1843
1844    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1845        mut map: V,
1846        optional: bool,
1847    ) -> Result<Option<Team>, V::Error> {
1848        let mut field_id = None;
1849        let mut field_name = None;
1850        let mut nothing = true;
1851        while let Some(key) = map.next_key::<&str>()? {
1852            nothing = false;
1853            match key {
1854                "id" => {
1855                    if field_id.is_some() {
1856                        return Err(::serde::de::Error::duplicate_field("id"));
1857                    }
1858                    field_id = Some(map.next_value()?);
1859                }
1860                "name" => {
1861                    if field_name.is_some() {
1862                        return Err(::serde::de::Error::duplicate_field("name"));
1863                    }
1864                    field_name = Some(map.next_value()?);
1865                }
1866                _ => {
1867                    // unknown field allowed and ignored
1868                    map.next_value::<::serde_json::Value>()?;
1869                }
1870            }
1871        }
1872        if optional && nothing {
1873            return Ok(None);
1874        }
1875        let result = Team {
1876            id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
1877            name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
1878        };
1879        Ok(Some(result))
1880    }
1881
1882    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1883        &self,
1884        s: &mut S::SerializeStruct,
1885    ) -> Result<(), S::Error> {
1886        use serde::ser::SerializeStruct;
1887        s.serialize_field("id", &self.id)?;
1888        s.serialize_field("name", &self.name)?;
1889        Ok(())
1890    }
1891}
1892
1893impl<'de> ::serde::de::Deserialize<'de> for Team {
1894    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1895        // struct deserializer
1896        use serde::de::{MapAccess, Visitor};
1897        struct StructVisitor;
1898        impl<'de> Visitor<'de> for StructVisitor {
1899            type Value = Team;
1900            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1901                f.write_str("a Team struct")
1902            }
1903            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1904                Team::internal_deserialize(map)
1905            }
1906        }
1907        deserializer.deserialize_struct("Team", TEAM_FIELDS, StructVisitor)
1908    }
1909}
1910
1911impl ::serde::ser::Serialize for Team {
1912    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1913        // struct serializer
1914        use serde::ser::SerializeStruct;
1915        let mut s = serializer.serialize_struct("Team", 2)?;
1916        self.internal_serialize::<S>(&mut s)?;
1917        s.end()
1918    }
1919}
1920
1921/// The value for [`UserFeature::TeamSharedDropbox`].
1922#[derive(Debug, Clone, PartialEq, Eq)]
1923#[non_exhaustive] // variants may be added in the future
1924pub enum TeamSharedDropboxValue {
1925    /// When this value is True, the user have a shared team root. When the value is False the user
1926    /// have distinct root.
1927    Enabled(bool),
1928    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1929    /// typically indicates that this SDK version is out of date.
1930    Other,
1931}
1932
1933impl<'de> ::serde::de::Deserialize<'de> for TeamSharedDropboxValue {
1934    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1935        // union deserializer
1936        use serde::de::{self, MapAccess, Visitor};
1937        struct EnumVisitor;
1938        impl<'de> Visitor<'de> for EnumVisitor {
1939            type Value = TeamSharedDropboxValue;
1940            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1941                f.write_str("a TeamSharedDropboxValue structure")
1942            }
1943            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1944                let tag: &str = match map.next_key()? {
1945                    Some(".tag") => map.next_value()?,
1946                    _ => return Err(de::Error::missing_field(".tag"))
1947                };
1948                let value = match tag {
1949                    "enabled" => {
1950                        match map.next_key()? {
1951                            Some("enabled") => TeamSharedDropboxValue::Enabled(map.next_value()?),
1952                            None => return Err(de::Error::missing_field("enabled")),
1953                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1954                        }
1955                    }
1956                    _ => TeamSharedDropboxValue::Other,
1957                };
1958                crate::eat_json_fields(&mut map)?;
1959                Ok(value)
1960            }
1961        }
1962        const VARIANTS: &[&str] = &["enabled",
1963                                    "other"];
1964        deserializer.deserialize_struct("TeamSharedDropboxValue", VARIANTS, EnumVisitor)
1965    }
1966}
1967
1968impl ::serde::ser::Serialize for TeamSharedDropboxValue {
1969    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1970        // union serializer
1971        use serde::ser::SerializeStruct;
1972        match self {
1973            TeamSharedDropboxValue::Enabled(x) => {
1974                // primitive
1975                let mut s = serializer.serialize_struct("TeamSharedDropboxValue", 2)?;
1976                s.serialize_field(".tag", "enabled")?;
1977                s.serialize_field("enabled", x)?;
1978                s.end()
1979            }
1980            TeamSharedDropboxValue::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1981        }
1982    }
1983}
1984
1985#[derive(Debug, Clone, PartialEq, Eq)]
1986#[non_exhaustive] // structs may have more fields added in the future.
1987pub struct TeamSpaceAllocation {
1988    /// The total space currently used by the user's team (bytes).
1989    pub used: u64,
1990    /// The total space allocated to the user's team (bytes).
1991    pub allocated: u64,
1992    /// The total space allocated to the user within its team allocated space (0 means that no
1993    /// restriction is imposed on the user's quota within its team).
1994    pub user_within_team_space_allocated: u64,
1995    /// The type of the space limit imposed on the team member (off, alert_only, stop_sync).
1996    pub user_within_team_space_limit_type: crate::types::team_common::MemberSpaceLimitType,
1997    /// An accurate cached calculation of a team member's total space usage (bytes).
1998    pub user_within_team_space_used_cached: u64,
1999}
2000
2001impl TeamSpaceAllocation {
2002    pub fn new(
2003        used: u64,
2004        allocated: u64,
2005        user_within_team_space_allocated: u64,
2006        user_within_team_space_limit_type: crate::types::team_common::MemberSpaceLimitType,
2007        user_within_team_space_used_cached: u64,
2008    ) -> Self {
2009        TeamSpaceAllocation {
2010            used,
2011            allocated,
2012            user_within_team_space_allocated,
2013            user_within_team_space_limit_type,
2014            user_within_team_space_used_cached,
2015        }
2016    }
2017}
2018
2019const TEAM_SPACE_ALLOCATION_FIELDS: &[&str] = &["used",
2020                                                "allocated",
2021                                                "user_within_team_space_allocated",
2022                                                "user_within_team_space_limit_type",
2023                                                "user_within_team_space_used_cached"];
2024impl TeamSpaceAllocation {
2025    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2026        map: V,
2027    ) -> Result<TeamSpaceAllocation, V::Error> {
2028        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2029    }
2030
2031    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2032        mut map: V,
2033        optional: bool,
2034    ) -> Result<Option<TeamSpaceAllocation>, V::Error> {
2035        let mut field_used = None;
2036        let mut field_allocated = None;
2037        let mut field_user_within_team_space_allocated = None;
2038        let mut field_user_within_team_space_limit_type = None;
2039        let mut field_user_within_team_space_used_cached = None;
2040        let mut nothing = true;
2041        while let Some(key) = map.next_key::<&str>()? {
2042            nothing = false;
2043            match key {
2044                "used" => {
2045                    if field_used.is_some() {
2046                        return Err(::serde::de::Error::duplicate_field("used"));
2047                    }
2048                    field_used = Some(map.next_value()?);
2049                }
2050                "allocated" => {
2051                    if field_allocated.is_some() {
2052                        return Err(::serde::de::Error::duplicate_field("allocated"));
2053                    }
2054                    field_allocated = Some(map.next_value()?);
2055                }
2056                "user_within_team_space_allocated" => {
2057                    if field_user_within_team_space_allocated.is_some() {
2058                        return Err(::serde::de::Error::duplicate_field("user_within_team_space_allocated"));
2059                    }
2060                    field_user_within_team_space_allocated = Some(map.next_value()?);
2061                }
2062                "user_within_team_space_limit_type" => {
2063                    if field_user_within_team_space_limit_type.is_some() {
2064                        return Err(::serde::de::Error::duplicate_field("user_within_team_space_limit_type"));
2065                    }
2066                    field_user_within_team_space_limit_type = Some(map.next_value()?);
2067                }
2068                "user_within_team_space_used_cached" => {
2069                    if field_user_within_team_space_used_cached.is_some() {
2070                        return Err(::serde::de::Error::duplicate_field("user_within_team_space_used_cached"));
2071                    }
2072                    field_user_within_team_space_used_cached = Some(map.next_value()?);
2073                }
2074                _ => {
2075                    // unknown field allowed and ignored
2076                    map.next_value::<::serde_json::Value>()?;
2077                }
2078            }
2079        }
2080        if optional && nothing {
2081            return Ok(None);
2082        }
2083        let result = TeamSpaceAllocation {
2084            used: field_used.ok_or_else(|| ::serde::de::Error::missing_field("used"))?,
2085            allocated: field_allocated.ok_or_else(|| ::serde::de::Error::missing_field("allocated"))?,
2086            user_within_team_space_allocated: field_user_within_team_space_allocated.ok_or_else(|| ::serde::de::Error::missing_field("user_within_team_space_allocated"))?,
2087            user_within_team_space_limit_type: field_user_within_team_space_limit_type.ok_or_else(|| ::serde::de::Error::missing_field("user_within_team_space_limit_type"))?,
2088            user_within_team_space_used_cached: field_user_within_team_space_used_cached.ok_or_else(|| ::serde::de::Error::missing_field("user_within_team_space_used_cached"))?,
2089        };
2090        Ok(Some(result))
2091    }
2092
2093    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2094        &self,
2095        s: &mut S::SerializeStruct,
2096    ) -> Result<(), S::Error> {
2097        use serde::ser::SerializeStruct;
2098        s.serialize_field("used", &self.used)?;
2099        s.serialize_field("allocated", &self.allocated)?;
2100        s.serialize_field("user_within_team_space_allocated", &self.user_within_team_space_allocated)?;
2101        s.serialize_field("user_within_team_space_limit_type", &self.user_within_team_space_limit_type)?;
2102        s.serialize_field("user_within_team_space_used_cached", &self.user_within_team_space_used_cached)?;
2103        Ok(())
2104    }
2105}
2106
2107impl<'de> ::serde::de::Deserialize<'de> for TeamSpaceAllocation {
2108    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2109        // struct deserializer
2110        use serde::de::{MapAccess, Visitor};
2111        struct StructVisitor;
2112        impl<'de> Visitor<'de> for StructVisitor {
2113            type Value = TeamSpaceAllocation;
2114            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2115                f.write_str("a TeamSpaceAllocation struct")
2116            }
2117            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2118                TeamSpaceAllocation::internal_deserialize(map)
2119            }
2120        }
2121        deserializer.deserialize_struct("TeamSpaceAllocation", TEAM_SPACE_ALLOCATION_FIELDS, StructVisitor)
2122    }
2123}
2124
2125impl ::serde::ser::Serialize for TeamSpaceAllocation {
2126    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2127        // struct serializer
2128        use serde::ser::SerializeStruct;
2129        let mut s = serializer.serialize_struct("TeamSpaceAllocation", 5)?;
2130        self.internal_serialize::<S>(&mut s)?;
2131        s.end()
2132    }
2133}
2134
2135/// A set of features that a Dropbox User account may have configured.
2136#[derive(Debug, Clone, PartialEq, Eq)]
2137#[non_exhaustive] // variants may be added in the future
2138pub enum UserFeature {
2139    /// This feature contains information about how the user's Paper files are stored.
2140    PaperAsFiles,
2141    /// This feature allows users to lock files in order to restrict other users from editing them.
2142    FileLocking,
2143    /// This feature contains information about whether or not the user is part of a team with a
2144    /// shared team root.
2145    TeamSharedDropbox,
2146    /// This feature contains information about whether or not the user's home namespace is distinct
2147    /// from their root namespace.
2148    DistinctMemberHome,
2149    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2150    /// typically indicates that this SDK version is out of date.
2151    Other,
2152}
2153
2154impl<'de> ::serde::de::Deserialize<'de> for UserFeature {
2155    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2156        // union deserializer
2157        use serde::de::{self, MapAccess, Visitor};
2158        struct EnumVisitor;
2159        impl<'de> Visitor<'de> for EnumVisitor {
2160            type Value = UserFeature;
2161            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2162                f.write_str("a UserFeature structure")
2163            }
2164            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2165                let tag: &str = match map.next_key()? {
2166                    Some(".tag") => map.next_value()?,
2167                    _ => return Err(de::Error::missing_field(".tag"))
2168                };
2169                let value = match tag {
2170                    "paper_as_files" => UserFeature::PaperAsFiles,
2171                    "file_locking" => UserFeature::FileLocking,
2172                    "team_shared_dropbox" => UserFeature::TeamSharedDropbox,
2173                    "distinct_member_home" => UserFeature::DistinctMemberHome,
2174                    _ => UserFeature::Other,
2175                };
2176                crate::eat_json_fields(&mut map)?;
2177                Ok(value)
2178            }
2179        }
2180        const VARIANTS: &[&str] = &["paper_as_files",
2181                                    "file_locking",
2182                                    "team_shared_dropbox",
2183                                    "distinct_member_home",
2184                                    "other"];
2185        deserializer.deserialize_struct("UserFeature", VARIANTS, EnumVisitor)
2186    }
2187}
2188
2189impl ::serde::ser::Serialize for UserFeature {
2190    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2191        // union serializer
2192        use serde::ser::SerializeStruct;
2193        match self {
2194            UserFeature::PaperAsFiles => {
2195                // unit
2196                let mut s = serializer.serialize_struct("UserFeature", 1)?;
2197                s.serialize_field(".tag", "paper_as_files")?;
2198                s.end()
2199            }
2200            UserFeature::FileLocking => {
2201                // unit
2202                let mut s = serializer.serialize_struct("UserFeature", 1)?;
2203                s.serialize_field(".tag", "file_locking")?;
2204                s.end()
2205            }
2206            UserFeature::TeamSharedDropbox => {
2207                // unit
2208                let mut s = serializer.serialize_struct("UserFeature", 1)?;
2209                s.serialize_field(".tag", "team_shared_dropbox")?;
2210                s.end()
2211            }
2212            UserFeature::DistinctMemberHome => {
2213                // unit
2214                let mut s = serializer.serialize_struct("UserFeature", 1)?;
2215                s.serialize_field(".tag", "distinct_member_home")?;
2216                s.end()
2217            }
2218            UserFeature::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2219        }
2220    }
2221}
2222
2223/// Values that correspond to entries in [`UserFeature`].
2224#[derive(Debug, Clone, PartialEq, Eq)]
2225#[non_exhaustive] // variants may be added in the future
2226pub enum UserFeatureValue {
2227    PaperAsFiles(PaperAsFilesValue),
2228    FileLocking(FileLockingValue),
2229    TeamSharedDropbox(TeamSharedDropboxValue),
2230    DistinctMemberHome(DistinctMemberHomeValue),
2231    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2232    /// typically indicates that this SDK version is out of date.
2233    Other,
2234}
2235
2236impl<'de> ::serde::de::Deserialize<'de> for UserFeatureValue {
2237    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2238        // union deserializer
2239        use serde::de::{self, MapAccess, Visitor};
2240        struct EnumVisitor;
2241        impl<'de> Visitor<'de> for EnumVisitor {
2242            type Value = UserFeatureValue;
2243            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2244                f.write_str("a UserFeatureValue structure")
2245            }
2246            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2247                let tag: &str = match map.next_key()? {
2248                    Some(".tag") => map.next_value()?,
2249                    _ => return Err(de::Error::missing_field(".tag"))
2250                };
2251                let value = match tag {
2252                    "paper_as_files" => {
2253                        match map.next_key()? {
2254                            Some("paper_as_files") => UserFeatureValue::PaperAsFiles(map.next_value()?),
2255                            None => return Err(de::Error::missing_field("paper_as_files")),
2256                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2257                        }
2258                    }
2259                    "file_locking" => {
2260                        match map.next_key()? {
2261                            Some("file_locking") => UserFeatureValue::FileLocking(map.next_value()?),
2262                            None => return Err(de::Error::missing_field("file_locking")),
2263                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2264                        }
2265                    }
2266                    "team_shared_dropbox" => {
2267                        match map.next_key()? {
2268                            Some("team_shared_dropbox") => UserFeatureValue::TeamSharedDropbox(map.next_value()?),
2269                            None => return Err(de::Error::missing_field("team_shared_dropbox")),
2270                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2271                        }
2272                    }
2273                    "distinct_member_home" => {
2274                        match map.next_key()? {
2275                            Some("distinct_member_home") => UserFeatureValue::DistinctMemberHome(map.next_value()?),
2276                            None => return Err(de::Error::missing_field("distinct_member_home")),
2277                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2278                        }
2279                    }
2280                    _ => UserFeatureValue::Other,
2281                };
2282                crate::eat_json_fields(&mut map)?;
2283                Ok(value)
2284            }
2285        }
2286        const VARIANTS: &[&str] = &["paper_as_files",
2287                                    "file_locking",
2288                                    "team_shared_dropbox",
2289                                    "distinct_member_home",
2290                                    "other"];
2291        deserializer.deserialize_struct("UserFeatureValue", VARIANTS, EnumVisitor)
2292    }
2293}
2294
2295impl ::serde::ser::Serialize for UserFeatureValue {
2296    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2297        // union serializer
2298        use serde::ser::SerializeStruct;
2299        match self {
2300            UserFeatureValue::PaperAsFiles(x) => {
2301                // union or polymporphic struct
2302                let mut s = serializer.serialize_struct("UserFeatureValue", 2)?;
2303                s.serialize_field(".tag", "paper_as_files")?;
2304                s.serialize_field("paper_as_files", x)?;
2305                s.end()
2306            }
2307            UserFeatureValue::FileLocking(x) => {
2308                // union or polymporphic struct
2309                let mut s = serializer.serialize_struct("UserFeatureValue", 2)?;
2310                s.serialize_field(".tag", "file_locking")?;
2311                s.serialize_field("file_locking", x)?;
2312                s.end()
2313            }
2314            UserFeatureValue::TeamSharedDropbox(x) => {
2315                // union or polymporphic struct
2316                let mut s = serializer.serialize_struct("UserFeatureValue", 2)?;
2317                s.serialize_field(".tag", "team_shared_dropbox")?;
2318                s.serialize_field("team_shared_dropbox", x)?;
2319                s.end()
2320            }
2321            UserFeatureValue::DistinctMemberHome(x) => {
2322                // union or polymporphic struct
2323                let mut s = serializer.serialize_struct("UserFeatureValue", 2)?;
2324                s.serialize_field(".tag", "distinct_member_home")?;
2325                s.serialize_field("distinct_member_home", x)?;
2326                s.end()
2327            }
2328            UserFeatureValue::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2329        }
2330    }
2331}
2332
2333#[derive(Debug, Clone, PartialEq, Eq)]
2334#[non_exhaustive] // structs may have more fields added in the future.
2335pub struct UserFeaturesGetValuesBatchArg {
2336    /// A list of features in [`UserFeature`]. If the list is empty, this route will return
2337    /// [`UserFeaturesGetValuesBatchError`].
2338    pub features: Vec<UserFeature>,
2339}
2340
2341impl UserFeaturesGetValuesBatchArg {
2342    pub fn new(features: Vec<UserFeature>) -> Self {
2343        UserFeaturesGetValuesBatchArg {
2344            features,
2345        }
2346    }
2347}
2348
2349const USER_FEATURES_GET_VALUES_BATCH_ARG_FIELDS: &[&str] = &["features"];
2350impl UserFeaturesGetValuesBatchArg {
2351    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2352        map: V,
2353    ) -> Result<UserFeaturesGetValuesBatchArg, V::Error> {
2354        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2355    }
2356
2357    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2358        mut map: V,
2359        optional: bool,
2360    ) -> Result<Option<UserFeaturesGetValuesBatchArg>, V::Error> {
2361        let mut field_features = None;
2362        let mut nothing = true;
2363        while let Some(key) = map.next_key::<&str>()? {
2364            nothing = false;
2365            match key {
2366                "features" => {
2367                    if field_features.is_some() {
2368                        return Err(::serde::de::Error::duplicate_field("features"));
2369                    }
2370                    field_features = Some(map.next_value()?);
2371                }
2372                _ => {
2373                    // unknown field allowed and ignored
2374                    map.next_value::<::serde_json::Value>()?;
2375                }
2376            }
2377        }
2378        if optional && nothing {
2379            return Ok(None);
2380        }
2381        let result = UserFeaturesGetValuesBatchArg {
2382            features: field_features.ok_or_else(|| ::serde::de::Error::missing_field("features"))?,
2383        };
2384        Ok(Some(result))
2385    }
2386
2387    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2388        &self,
2389        s: &mut S::SerializeStruct,
2390    ) -> Result<(), S::Error> {
2391        use serde::ser::SerializeStruct;
2392        s.serialize_field("features", &self.features)?;
2393        Ok(())
2394    }
2395}
2396
2397impl<'de> ::serde::de::Deserialize<'de> for UserFeaturesGetValuesBatchArg {
2398    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2399        // struct deserializer
2400        use serde::de::{MapAccess, Visitor};
2401        struct StructVisitor;
2402        impl<'de> Visitor<'de> for StructVisitor {
2403            type Value = UserFeaturesGetValuesBatchArg;
2404            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2405                f.write_str("a UserFeaturesGetValuesBatchArg struct")
2406            }
2407            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2408                UserFeaturesGetValuesBatchArg::internal_deserialize(map)
2409            }
2410        }
2411        deserializer.deserialize_struct("UserFeaturesGetValuesBatchArg", USER_FEATURES_GET_VALUES_BATCH_ARG_FIELDS, StructVisitor)
2412    }
2413}
2414
2415impl ::serde::ser::Serialize for UserFeaturesGetValuesBatchArg {
2416    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2417        // struct serializer
2418        use serde::ser::SerializeStruct;
2419        let mut s = serializer.serialize_struct("UserFeaturesGetValuesBatchArg", 1)?;
2420        self.internal_serialize::<S>(&mut s)?;
2421        s.end()
2422    }
2423}
2424
2425#[derive(Debug, Clone, PartialEq, Eq)]
2426#[non_exhaustive] // variants may be added in the future
2427pub enum UserFeaturesGetValuesBatchError {
2428    /// At least one [`UserFeature`] must be included in the
2429    /// [`UserFeaturesGetValuesBatchArg`].features list.
2430    EmptyFeaturesList,
2431    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2432    /// typically indicates that this SDK version is out of date.
2433    Other,
2434}
2435
2436impl<'de> ::serde::de::Deserialize<'de> for UserFeaturesGetValuesBatchError {
2437    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2438        // union deserializer
2439        use serde::de::{self, MapAccess, Visitor};
2440        struct EnumVisitor;
2441        impl<'de> Visitor<'de> for EnumVisitor {
2442            type Value = UserFeaturesGetValuesBatchError;
2443            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2444                f.write_str("a UserFeaturesGetValuesBatchError structure")
2445            }
2446            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2447                let tag: &str = match map.next_key()? {
2448                    Some(".tag") => map.next_value()?,
2449                    _ => return Err(de::Error::missing_field(".tag"))
2450                };
2451                let value = match tag {
2452                    "empty_features_list" => UserFeaturesGetValuesBatchError::EmptyFeaturesList,
2453                    _ => UserFeaturesGetValuesBatchError::Other,
2454                };
2455                crate::eat_json_fields(&mut map)?;
2456                Ok(value)
2457            }
2458        }
2459        const VARIANTS: &[&str] = &["empty_features_list",
2460                                    "other"];
2461        deserializer.deserialize_struct("UserFeaturesGetValuesBatchError", VARIANTS, EnumVisitor)
2462    }
2463}
2464
2465impl ::serde::ser::Serialize for UserFeaturesGetValuesBatchError {
2466    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2467        // union serializer
2468        use serde::ser::SerializeStruct;
2469        match self {
2470            UserFeaturesGetValuesBatchError::EmptyFeaturesList => {
2471                // unit
2472                let mut s = serializer.serialize_struct("UserFeaturesGetValuesBatchError", 1)?;
2473                s.serialize_field(".tag", "empty_features_list")?;
2474                s.end()
2475            }
2476            UserFeaturesGetValuesBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2477        }
2478    }
2479}
2480
2481impl ::std::error::Error for UserFeaturesGetValuesBatchError {
2482}
2483
2484impl ::std::fmt::Display for UserFeaturesGetValuesBatchError {
2485    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2486        write!(f, "{:?}", *self)
2487    }
2488}
2489
2490#[derive(Debug, Clone, PartialEq, Eq)]
2491#[non_exhaustive] // structs may have more fields added in the future.
2492pub struct UserFeaturesGetValuesBatchResult {
2493    pub values: Vec<UserFeatureValue>,
2494}
2495
2496impl UserFeaturesGetValuesBatchResult {
2497    pub fn new(values: Vec<UserFeatureValue>) -> Self {
2498        UserFeaturesGetValuesBatchResult {
2499            values,
2500        }
2501    }
2502}
2503
2504const USER_FEATURES_GET_VALUES_BATCH_RESULT_FIELDS: &[&str] = &["values"];
2505impl UserFeaturesGetValuesBatchResult {
2506    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2507        map: V,
2508    ) -> Result<UserFeaturesGetValuesBatchResult, V::Error> {
2509        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2510    }
2511
2512    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2513        mut map: V,
2514        optional: bool,
2515    ) -> Result<Option<UserFeaturesGetValuesBatchResult>, V::Error> {
2516        let mut field_values = None;
2517        let mut nothing = true;
2518        while let Some(key) = map.next_key::<&str>()? {
2519            nothing = false;
2520            match key {
2521                "values" => {
2522                    if field_values.is_some() {
2523                        return Err(::serde::de::Error::duplicate_field("values"));
2524                    }
2525                    field_values = Some(map.next_value()?);
2526                }
2527                _ => {
2528                    // unknown field allowed and ignored
2529                    map.next_value::<::serde_json::Value>()?;
2530                }
2531            }
2532        }
2533        if optional && nothing {
2534            return Ok(None);
2535        }
2536        let result = UserFeaturesGetValuesBatchResult {
2537            values: field_values.ok_or_else(|| ::serde::de::Error::missing_field("values"))?,
2538        };
2539        Ok(Some(result))
2540    }
2541
2542    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2543        &self,
2544        s: &mut S::SerializeStruct,
2545    ) -> Result<(), S::Error> {
2546        use serde::ser::SerializeStruct;
2547        s.serialize_field("values", &self.values)?;
2548        Ok(())
2549    }
2550}
2551
2552impl<'de> ::serde::de::Deserialize<'de> for UserFeaturesGetValuesBatchResult {
2553    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2554        // struct deserializer
2555        use serde::de::{MapAccess, Visitor};
2556        struct StructVisitor;
2557        impl<'de> Visitor<'de> for StructVisitor {
2558            type Value = UserFeaturesGetValuesBatchResult;
2559            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2560                f.write_str("a UserFeaturesGetValuesBatchResult struct")
2561            }
2562            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2563                UserFeaturesGetValuesBatchResult::internal_deserialize(map)
2564            }
2565        }
2566        deserializer.deserialize_struct("UserFeaturesGetValuesBatchResult", USER_FEATURES_GET_VALUES_BATCH_RESULT_FIELDS, StructVisitor)
2567    }
2568}
2569
2570impl ::serde::ser::Serialize for UserFeaturesGetValuesBatchResult {
2571    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2572        // struct serializer
2573        use serde::ser::SerializeStruct;
2574        let mut s = serializer.serialize_struct("UserFeaturesGetValuesBatchResult", 1)?;
2575        self.internal_serialize::<S>(&mut s)?;
2576        s.end()
2577    }
2578}
2579