Skip to main content

dropbox_sdk/generated/types/
account.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#[derive(Debug, Clone, PartialEq, Eq)]
13#[non_exhaustive] // structs may have more fields added in the future.
14pub struct AccountPhotoGetArg {
15    /// Encoded ID of the user. Must start either with 'dbid:' or 'dbaphid:'.
16    pub dbx_account_id: String,
17    /// A string representing the size of the photo.
18    pub size: String,
19    /// True if the photo should be cropped and false otherwise.
20    pub circle_crop: bool,
21    /// True if we expect account photo to exist.
22    pub expect_account_photo: bool,
23}
24
25impl AccountPhotoGetArg {
26    pub fn new(
27        dbx_account_id: String,
28        size: String,
29        circle_crop: bool,
30        expect_account_photo: bool,
31    ) -> Self {
32        AccountPhotoGetArg {
33            dbx_account_id,
34            size,
35            circle_crop,
36            expect_account_photo,
37        }
38    }
39}
40
41const ACCOUNT_PHOTO_GET_ARG_FIELDS: &[&str] = &["dbx_account_id",
42                                                "size",
43                                                "circle_crop",
44                                                "expect_account_photo"];
45impl AccountPhotoGetArg {
46    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
47        map: V,
48    ) -> Result<AccountPhotoGetArg, V::Error> {
49        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
50    }
51
52    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
53        mut map: V,
54        optional: bool,
55    ) -> Result<Option<AccountPhotoGetArg>, V::Error> {
56        let mut field_dbx_account_id = None;
57        let mut field_size = None;
58        let mut field_circle_crop = None;
59        let mut field_expect_account_photo = None;
60        let mut nothing = true;
61        while let Some(key) = map.next_key::<&str>()? {
62            nothing = false;
63            match key {
64                "dbx_account_id" => {
65                    if field_dbx_account_id.is_some() {
66                        return Err(::serde::de::Error::duplicate_field("dbx_account_id"));
67                    }
68                    field_dbx_account_id = Some(map.next_value()?);
69                }
70                "size" => {
71                    if field_size.is_some() {
72                        return Err(::serde::de::Error::duplicate_field("size"));
73                    }
74                    field_size = Some(map.next_value()?);
75                }
76                "circle_crop" => {
77                    if field_circle_crop.is_some() {
78                        return Err(::serde::de::Error::duplicate_field("circle_crop"));
79                    }
80                    field_circle_crop = Some(map.next_value()?);
81                }
82                "expect_account_photo" => {
83                    if field_expect_account_photo.is_some() {
84                        return Err(::serde::de::Error::duplicate_field("expect_account_photo"));
85                    }
86                    field_expect_account_photo = Some(map.next_value()?);
87                }
88                _ => {
89                    // unknown field allowed and ignored
90                    map.next_value::<::serde_json::Value>()?;
91                }
92            }
93        }
94        if optional && nothing {
95            return Ok(None);
96        }
97        let result = AccountPhotoGetArg {
98            dbx_account_id: field_dbx_account_id.ok_or_else(|| ::serde::de::Error::missing_field("dbx_account_id"))?,
99            size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
100            circle_crop: field_circle_crop.ok_or_else(|| ::serde::de::Error::missing_field("circle_crop"))?,
101            expect_account_photo: field_expect_account_photo.ok_or_else(|| ::serde::de::Error::missing_field("expect_account_photo"))?,
102        };
103        Ok(Some(result))
104    }
105
106    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
107        &self,
108        s: &mut S::SerializeStruct,
109    ) -> Result<(), S::Error> {
110        use serde::ser::SerializeStruct;
111        s.serialize_field("dbx_account_id", &self.dbx_account_id)?;
112        s.serialize_field("size", &self.size)?;
113        s.serialize_field("circle_crop", &self.circle_crop)?;
114        s.serialize_field("expect_account_photo", &self.expect_account_photo)?;
115        Ok(())
116    }
117}
118
119impl<'de> ::serde::de::Deserialize<'de> for AccountPhotoGetArg {
120    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
121        // struct deserializer
122        use serde::de::{MapAccess, Visitor};
123        struct StructVisitor;
124        impl<'de> Visitor<'de> for StructVisitor {
125            type Value = AccountPhotoGetArg;
126            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
127                f.write_str("a AccountPhotoGetArg struct")
128            }
129            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
130                AccountPhotoGetArg::internal_deserialize(map)
131            }
132        }
133        deserializer.deserialize_struct("AccountPhotoGetArg", ACCOUNT_PHOTO_GET_ARG_FIELDS, StructVisitor)
134    }
135}
136
137impl ::serde::ser::Serialize for AccountPhotoGetArg {
138    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
139        // struct serializer
140        use serde::ser::SerializeStruct;
141        let mut s = serializer.serialize_struct("AccountPhotoGetArg", 4)?;
142        self.internal_serialize::<S>(&mut s)?;
143        s.end()
144    }
145}
146
147#[derive(Debug, Clone, PartialEq, Eq)]
148#[non_exhaustive] // variants may be added in the future
149pub enum AccountPhotoGetError {
150    /// Indicates infrastructural failure.
151    ThumbnailError(ThumbnailError),
152    /// Account photo is missing (but we did not expect it to exist).
153    AccountPhotoMissing,
154    /// Account photo was expected to exist, but it's missing.
155    ExpectedAccountPhotoMissing,
156    /// Catch-all used for unrecognized values returned from the server. Encountering this value
157    /// typically indicates that this SDK version is out of date.
158    Other,
159}
160
161impl<'de> ::serde::de::Deserialize<'de> for AccountPhotoGetError {
162    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
163        // union deserializer
164        use serde::de::{self, MapAccess, Visitor};
165        struct EnumVisitor;
166        impl<'de> Visitor<'de> for EnumVisitor {
167            type Value = AccountPhotoGetError;
168            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
169                f.write_str("a AccountPhotoGetError structure")
170            }
171            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
172                let tag: &str = match map.next_key()? {
173                    Some(".tag") => map.next_value()?,
174                    _ => return Err(de::Error::missing_field(".tag"))
175                };
176                let value = match tag {
177                    "thumbnail_error" => {
178                        match map.next_key()? {
179                            Some("thumbnail_error") => AccountPhotoGetError::ThumbnailError(map.next_value()?),
180                            None => return Err(de::Error::missing_field("thumbnail_error")),
181                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
182                        }
183                    }
184                    "account_photo_missing" => AccountPhotoGetError::AccountPhotoMissing,
185                    "expected_account_photo_missing" => AccountPhotoGetError::ExpectedAccountPhotoMissing,
186                    _ => AccountPhotoGetError::Other,
187                };
188                crate::eat_json_fields(&mut map)?;
189                Ok(value)
190            }
191        }
192        const VARIANTS: &[&str] = &["thumbnail_error",
193                                    "account_photo_missing",
194                                    "expected_account_photo_missing",
195                                    "other"];
196        deserializer.deserialize_struct("AccountPhotoGetError", VARIANTS, EnumVisitor)
197    }
198}
199
200impl ::serde::ser::Serialize for AccountPhotoGetError {
201    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
202        // union serializer
203        use serde::ser::SerializeStruct;
204        match self {
205            AccountPhotoGetError::ThumbnailError(x) => {
206                // union or polymporphic struct
207                let mut s = serializer.serialize_struct("AccountPhotoGetError", 2)?;
208                s.serialize_field(".tag", "thumbnail_error")?;
209                s.serialize_field("thumbnail_error", x)?;
210                s.end()
211            }
212            AccountPhotoGetError::AccountPhotoMissing => {
213                // unit
214                let mut s = serializer.serialize_struct("AccountPhotoGetError", 1)?;
215                s.serialize_field(".tag", "account_photo_missing")?;
216                s.end()
217            }
218            AccountPhotoGetError::ExpectedAccountPhotoMissing => {
219                // unit
220                let mut s = serializer.serialize_struct("AccountPhotoGetError", 1)?;
221                s.serialize_field(".tag", "expected_account_photo_missing")?;
222                s.end()
223            }
224            AccountPhotoGetError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
225        }
226    }
227}
228
229impl ::std::error::Error for AccountPhotoGetError {
230    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
231        match self {
232            AccountPhotoGetError::ThumbnailError(inner) => Some(inner),
233            _ => None,
234        }
235    }
236}
237
238impl ::std::fmt::Display for AccountPhotoGetError {
239    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
240        match self {
241            AccountPhotoGetError::ThumbnailError(inner) => write!(f, "Indicates infrastructural failure: {}", inner),
242            AccountPhotoGetError::AccountPhotoMissing => f.write_str("Account photo is missing (but we did not expect it to exist)."),
243            AccountPhotoGetError::ExpectedAccountPhotoMissing => f.write_str("Account photo was expected to exist, but it's missing."),
244            _ => write!(f, "{:?}", *self),
245        }
246    }
247}
248
249#[derive(Debug, Clone, PartialEq, Eq)]
250#[non_exhaustive] // structs may have more fields added in the future.
251pub struct AccountPhotoGetResult {
252    /// The data returned by get_photo.
253    pub content_type: String,
254}
255
256impl AccountPhotoGetResult {
257    pub fn new(content_type: String) -> Self {
258        AccountPhotoGetResult {
259            content_type,
260        }
261    }
262}
263
264const ACCOUNT_PHOTO_GET_RESULT_FIELDS: &[&str] = &["content_type"];
265impl AccountPhotoGetResult {
266    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
267        map: V,
268    ) -> Result<AccountPhotoGetResult, V::Error> {
269        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
270    }
271
272    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
273        mut map: V,
274        optional: bool,
275    ) -> Result<Option<AccountPhotoGetResult>, V::Error> {
276        let mut field_content_type = None;
277        let mut nothing = true;
278        while let Some(key) = map.next_key::<&str>()? {
279            nothing = false;
280            match key {
281                "content_type" => {
282                    if field_content_type.is_some() {
283                        return Err(::serde::de::Error::duplicate_field("content_type"));
284                    }
285                    field_content_type = Some(map.next_value()?);
286                }
287                _ => {
288                    // unknown field allowed and ignored
289                    map.next_value::<::serde_json::Value>()?;
290                }
291            }
292        }
293        if optional && nothing {
294            return Ok(None);
295        }
296        let result = AccountPhotoGetResult {
297            content_type: field_content_type.ok_or_else(|| ::serde::de::Error::missing_field("content_type"))?,
298        };
299        Ok(Some(result))
300    }
301
302    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
303        &self,
304        s: &mut S::SerializeStruct,
305    ) -> Result<(), S::Error> {
306        use serde::ser::SerializeStruct;
307        s.serialize_field("content_type", &self.content_type)?;
308        Ok(())
309    }
310}
311
312impl<'de> ::serde::de::Deserialize<'de> for AccountPhotoGetResult {
313    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
314        // struct deserializer
315        use serde::de::{MapAccess, Visitor};
316        struct StructVisitor;
317        impl<'de> Visitor<'de> for StructVisitor {
318            type Value = AccountPhotoGetResult;
319            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
320                f.write_str("a AccountPhotoGetResult struct")
321            }
322            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
323                AccountPhotoGetResult::internal_deserialize(map)
324            }
325        }
326        deserializer.deserialize_struct("AccountPhotoGetResult", ACCOUNT_PHOTO_GET_RESULT_FIELDS, StructVisitor)
327    }
328}
329
330impl ::serde::ser::Serialize for AccountPhotoGetResult {
331    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
332        // struct serializer
333        use serde::ser::SerializeStruct;
334        let mut s = serializer.serialize_struct("AccountPhotoGetResult", 1)?;
335        self.internal_serialize::<S>(&mut s)?;
336        s.end()
337    }
338}
339
340/// This struct is empty. The comment here is intentionally emitted to avoid indentation issues with
341/// Stone.
342#[derive(Debug, Clone, PartialEq, Eq, Default)]
343#[non_exhaustive] // structs may have more fields added in the future.
344pub struct DeleteProfilePhotoArg {
345}
346
347const DELETE_PROFILE_PHOTO_ARG_FIELDS: &[&str] = &[];
348impl DeleteProfilePhotoArg {
349    // no _opt deserializer
350    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
351        mut map: V,
352    ) -> Result<DeleteProfilePhotoArg, V::Error> {
353        // ignore any fields found; none are presently recognized
354        crate::eat_json_fields(&mut map)?;
355        Ok(DeleteProfilePhotoArg {})
356    }
357}
358
359impl<'de> ::serde::de::Deserialize<'de> for DeleteProfilePhotoArg {
360    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
361        // struct deserializer
362        use serde::de::{MapAccess, Visitor};
363        struct StructVisitor;
364        impl<'de> Visitor<'de> for StructVisitor {
365            type Value = DeleteProfilePhotoArg;
366            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
367                f.write_str("a DeleteProfilePhotoArg struct")
368            }
369            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
370                DeleteProfilePhotoArg::internal_deserialize(map)
371            }
372        }
373        deserializer.deserialize_struct("DeleteProfilePhotoArg", DELETE_PROFILE_PHOTO_ARG_FIELDS, StructVisitor)
374    }
375}
376
377impl ::serde::ser::Serialize for DeleteProfilePhotoArg {
378    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
379        // struct serializer
380        use serde::ser::SerializeStruct;
381        serializer.serialize_struct("DeleteProfilePhotoArg", 0)?.end()
382    }
383}
384
385/// This union is empty. The comment here is intentionally emitted to avoid indentation issues with
386/// Stone.
387#[derive(Debug, Clone, PartialEq, Eq)]
388#[non_exhaustive] // variants may be added in the future
389pub enum DeleteProfilePhotoError {
390    /// Catch-all used for unrecognized values returned from the server. Encountering this value
391    /// typically indicates that this SDK version is out of date.
392    Other,
393}
394
395impl<'de> ::serde::de::Deserialize<'de> for DeleteProfilePhotoError {
396    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
397        // union deserializer
398        use serde::de::{self, MapAccess, Visitor};
399        struct EnumVisitor;
400        impl<'de> Visitor<'de> for EnumVisitor {
401            type Value = DeleteProfilePhotoError;
402            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
403                f.write_str("a DeleteProfilePhotoError structure")
404            }
405            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
406                let tag: &str = match map.next_key()? {
407                    Some(".tag") => map.next_value()?,
408                    _ => return Err(de::Error::missing_field(".tag"))
409                };
410                // open enum with no defined variants
411                let _ = tag;
412                crate::eat_json_fields(&mut map)?;
413                Ok(DeleteProfilePhotoError::Other)
414            }
415        }
416        const VARIANTS: &[&str] = &["other"];
417        deserializer.deserialize_struct("DeleteProfilePhotoError", VARIANTS, EnumVisitor)
418    }
419}
420
421impl ::serde::ser::Serialize for DeleteProfilePhotoError {
422    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
423        // union serializer
424        #![allow(unused_variables)]
425        Err(::serde::ser::Error::custom("cannot serialize an open union with no defined variants"))
426    }
427}
428
429impl ::std::error::Error for DeleteProfilePhotoError {
430}
431
432impl ::std::fmt::Display for DeleteProfilePhotoError {
433    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
434        write!(f, "{:?}", *self)
435    }
436}
437
438/// This struct is empty. The comment here is intentionally emitted to avoid indentation issues with
439/// Stone.
440#[derive(Debug, Clone, PartialEq, Eq, Default)]
441#[non_exhaustive] // structs may have more fields added in the future.
442pub struct DeleteProfilePhotoResult {
443}
444
445const DELETE_PROFILE_PHOTO_RESULT_FIELDS: &[&str] = &[];
446impl DeleteProfilePhotoResult {
447    // no _opt deserializer
448    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
449        mut map: V,
450    ) -> Result<DeleteProfilePhotoResult, V::Error> {
451        // ignore any fields found; none are presently recognized
452        crate::eat_json_fields(&mut map)?;
453        Ok(DeleteProfilePhotoResult {})
454    }
455}
456
457impl<'de> ::serde::de::Deserialize<'de> for DeleteProfilePhotoResult {
458    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
459        // struct deserializer
460        use serde::de::{MapAccess, Visitor};
461        struct StructVisitor;
462        impl<'de> Visitor<'de> for StructVisitor {
463            type Value = DeleteProfilePhotoResult;
464            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
465                f.write_str("a DeleteProfilePhotoResult struct")
466            }
467            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
468                DeleteProfilePhotoResult::internal_deserialize(map)
469            }
470        }
471        deserializer.deserialize_struct("DeleteProfilePhotoResult", DELETE_PROFILE_PHOTO_RESULT_FIELDS, StructVisitor)
472    }
473}
474
475impl ::serde::ser::Serialize for DeleteProfilePhotoResult {
476    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
477        // struct serializer
478        use serde::ser::SerializeStruct;
479        serializer.serialize_struct("DeleteProfilePhotoResult", 0)?.end()
480    }
481}
482
483#[derive(Debug, Clone, PartialEq, Eq)]
484#[non_exhaustive] // variants may be added in the future
485pub enum PhotoSourceArg {
486    /// Image data in base64-encoded bytes.
487    Base64Data(String),
488    /// Catch-all used for unrecognized values returned from the server. Encountering this value
489    /// typically indicates that this SDK version is out of date.
490    Other,
491}
492
493impl<'de> ::serde::de::Deserialize<'de> for PhotoSourceArg {
494    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
495        // union deserializer
496        use serde::de::{self, MapAccess, Visitor};
497        struct EnumVisitor;
498        impl<'de> Visitor<'de> for EnumVisitor {
499            type Value = PhotoSourceArg;
500            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
501                f.write_str("a PhotoSourceArg structure")
502            }
503            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
504                let tag: &str = match map.next_key()? {
505                    Some(".tag") => map.next_value()?,
506                    _ => return Err(de::Error::missing_field(".tag"))
507                };
508                let value = match tag {
509                    "base64_data" => {
510                        match map.next_key()? {
511                            Some("base64_data") => PhotoSourceArg::Base64Data(map.next_value()?),
512                            None => return Err(de::Error::missing_field("base64_data")),
513                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
514                        }
515                    }
516                    _ => PhotoSourceArg::Other,
517                };
518                crate::eat_json_fields(&mut map)?;
519                Ok(value)
520            }
521        }
522        const VARIANTS: &[&str] = &["base64_data",
523                                    "other"];
524        deserializer.deserialize_struct("PhotoSourceArg", VARIANTS, EnumVisitor)
525    }
526}
527
528impl ::serde::ser::Serialize for PhotoSourceArg {
529    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
530        // union serializer
531        use serde::ser::SerializeStruct;
532        match self {
533            PhotoSourceArg::Base64Data(x) => {
534                // primitive
535                let mut s = serializer.serialize_struct("PhotoSourceArg", 2)?;
536                s.serialize_field(".tag", "base64_data")?;
537                s.serialize_field("base64_data", x)?;
538                s.end()
539            }
540            PhotoSourceArg::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
541        }
542    }
543}
544
545#[derive(Debug, Clone, PartialEq, Eq)]
546#[non_exhaustive] // structs may have more fields added in the future.
547pub struct SetProfilePhotoArg {
548    /// Image to set as the user's new profile photo.
549    pub photo: PhotoSourceArg,
550}
551
552impl SetProfilePhotoArg {
553    pub fn new(photo: PhotoSourceArg) -> Self {
554        SetProfilePhotoArg {
555            photo,
556        }
557    }
558}
559
560const SET_PROFILE_PHOTO_ARG_FIELDS: &[&str] = &["photo"];
561impl SetProfilePhotoArg {
562    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
563        map: V,
564    ) -> Result<SetProfilePhotoArg, V::Error> {
565        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
566    }
567
568    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
569        mut map: V,
570        optional: bool,
571    ) -> Result<Option<SetProfilePhotoArg>, V::Error> {
572        let mut field_photo = None;
573        let mut nothing = true;
574        while let Some(key) = map.next_key::<&str>()? {
575            nothing = false;
576            match key {
577                "photo" => {
578                    if field_photo.is_some() {
579                        return Err(::serde::de::Error::duplicate_field("photo"));
580                    }
581                    field_photo = Some(map.next_value()?);
582                }
583                _ => {
584                    // unknown field allowed and ignored
585                    map.next_value::<::serde_json::Value>()?;
586                }
587            }
588        }
589        if optional && nothing {
590            return Ok(None);
591        }
592        let result = SetProfilePhotoArg {
593            photo: field_photo.ok_or_else(|| ::serde::de::Error::missing_field("photo"))?,
594        };
595        Ok(Some(result))
596    }
597
598    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
599        &self,
600        s: &mut S::SerializeStruct,
601    ) -> Result<(), S::Error> {
602        use serde::ser::SerializeStruct;
603        s.serialize_field("photo", &self.photo)?;
604        Ok(())
605    }
606}
607
608impl<'de> ::serde::de::Deserialize<'de> for SetProfilePhotoArg {
609    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
610        // struct deserializer
611        use serde::de::{MapAccess, Visitor};
612        struct StructVisitor;
613        impl<'de> Visitor<'de> for StructVisitor {
614            type Value = SetProfilePhotoArg;
615            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
616                f.write_str("a SetProfilePhotoArg struct")
617            }
618            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
619                SetProfilePhotoArg::internal_deserialize(map)
620            }
621        }
622        deserializer.deserialize_struct("SetProfilePhotoArg", SET_PROFILE_PHOTO_ARG_FIELDS, StructVisitor)
623    }
624}
625
626impl ::serde::ser::Serialize for SetProfilePhotoArg {
627    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
628        // struct serializer
629        use serde::ser::SerializeStruct;
630        let mut s = serializer.serialize_struct("SetProfilePhotoArg", 1)?;
631        self.internal_serialize::<S>(&mut s)?;
632        s.end()
633    }
634}
635
636#[derive(Debug, Clone, PartialEq, Eq)]
637#[non_exhaustive] // variants may be added in the future
638pub enum SetProfilePhotoError {
639    /// File cannot be set as profile photo.
640    FileTypeError,
641    /// File cannot exceed 10 MB.
642    FileSizeError,
643    /// Image must be larger than 128 x 128.
644    DimensionError,
645    /// Image could not be thumbnailed.
646    ThumbnailError,
647    /// Temporary infrastructure failure, please retry.
648    TransientError,
649    /// Catch-all used for unrecognized values returned from the server. Encountering this value
650    /// typically indicates that this SDK version is out of date.
651    Other,
652}
653
654impl<'de> ::serde::de::Deserialize<'de> for SetProfilePhotoError {
655    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
656        // union deserializer
657        use serde::de::{self, MapAccess, Visitor};
658        struct EnumVisitor;
659        impl<'de> Visitor<'de> for EnumVisitor {
660            type Value = SetProfilePhotoError;
661            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
662                f.write_str("a SetProfilePhotoError structure")
663            }
664            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
665                let tag: &str = match map.next_key()? {
666                    Some(".tag") => map.next_value()?,
667                    _ => return Err(de::Error::missing_field(".tag"))
668                };
669                let value = match tag {
670                    "file_type_error" => SetProfilePhotoError::FileTypeError,
671                    "file_size_error" => SetProfilePhotoError::FileSizeError,
672                    "dimension_error" => SetProfilePhotoError::DimensionError,
673                    "thumbnail_error" => SetProfilePhotoError::ThumbnailError,
674                    "transient_error" => SetProfilePhotoError::TransientError,
675                    _ => SetProfilePhotoError::Other,
676                };
677                crate::eat_json_fields(&mut map)?;
678                Ok(value)
679            }
680        }
681        const VARIANTS: &[&str] = &["file_type_error",
682                                    "file_size_error",
683                                    "dimension_error",
684                                    "thumbnail_error",
685                                    "transient_error",
686                                    "other"];
687        deserializer.deserialize_struct("SetProfilePhotoError", VARIANTS, EnumVisitor)
688    }
689}
690
691impl ::serde::ser::Serialize for SetProfilePhotoError {
692    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
693        // union serializer
694        use serde::ser::SerializeStruct;
695        match self {
696            SetProfilePhotoError::FileTypeError => {
697                // unit
698                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
699                s.serialize_field(".tag", "file_type_error")?;
700                s.end()
701            }
702            SetProfilePhotoError::FileSizeError => {
703                // unit
704                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
705                s.serialize_field(".tag", "file_size_error")?;
706                s.end()
707            }
708            SetProfilePhotoError::DimensionError => {
709                // unit
710                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
711                s.serialize_field(".tag", "dimension_error")?;
712                s.end()
713            }
714            SetProfilePhotoError::ThumbnailError => {
715                // unit
716                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
717                s.serialize_field(".tag", "thumbnail_error")?;
718                s.end()
719            }
720            SetProfilePhotoError::TransientError => {
721                // unit
722                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
723                s.serialize_field(".tag", "transient_error")?;
724                s.end()
725            }
726            SetProfilePhotoError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
727        }
728    }
729}
730
731impl ::std::error::Error for SetProfilePhotoError {
732}
733
734impl ::std::fmt::Display for SetProfilePhotoError {
735    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
736        match self {
737            SetProfilePhotoError::FileTypeError => f.write_str("File cannot be set as profile photo."),
738            SetProfilePhotoError::FileSizeError => f.write_str("File cannot exceed 10 MB."),
739            SetProfilePhotoError::DimensionError => f.write_str("Image must be larger than 128 x 128."),
740            SetProfilePhotoError::ThumbnailError => f.write_str("Image could not be thumbnailed."),
741            SetProfilePhotoError::TransientError => f.write_str("Temporary infrastructure failure, please retry."),
742            _ => write!(f, "{:?}", *self),
743        }
744    }
745}
746
747#[derive(Debug, Clone, PartialEq, Eq)]
748#[non_exhaustive] // structs may have more fields added in the future.
749pub struct SetProfilePhotoResult {
750    /// URL for the photo representing the user, if one is set.
751    pub profile_photo_url: String,
752}
753
754impl SetProfilePhotoResult {
755    pub fn new(profile_photo_url: String) -> Self {
756        SetProfilePhotoResult {
757            profile_photo_url,
758        }
759    }
760}
761
762const SET_PROFILE_PHOTO_RESULT_FIELDS: &[&str] = &["profile_photo_url"];
763impl SetProfilePhotoResult {
764    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
765        map: V,
766    ) -> Result<SetProfilePhotoResult, V::Error> {
767        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
768    }
769
770    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
771        mut map: V,
772        optional: bool,
773    ) -> Result<Option<SetProfilePhotoResult>, V::Error> {
774        let mut field_profile_photo_url = None;
775        let mut nothing = true;
776        while let Some(key) = map.next_key::<&str>()? {
777            nothing = false;
778            match key {
779                "profile_photo_url" => {
780                    if field_profile_photo_url.is_some() {
781                        return Err(::serde::de::Error::duplicate_field("profile_photo_url"));
782                    }
783                    field_profile_photo_url = Some(map.next_value()?);
784                }
785                _ => {
786                    // unknown field allowed and ignored
787                    map.next_value::<::serde_json::Value>()?;
788                }
789            }
790        }
791        if optional && nothing {
792            return Ok(None);
793        }
794        let result = SetProfilePhotoResult {
795            profile_photo_url: field_profile_photo_url.ok_or_else(|| ::serde::de::Error::missing_field("profile_photo_url"))?,
796        };
797        Ok(Some(result))
798    }
799
800    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
801        &self,
802        s: &mut S::SerializeStruct,
803    ) -> Result<(), S::Error> {
804        use serde::ser::SerializeStruct;
805        s.serialize_field("profile_photo_url", &self.profile_photo_url)?;
806        Ok(())
807    }
808}
809
810impl<'de> ::serde::de::Deserialize<'de> for SetProfilePhotoResult {
811    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
812        // struct deserializer
813        use serde::de::{MapAccess, Visitor};
814        struct StructVisitor;
815        impl<'de> Visitor<'de> for StructVisitor {
816            type Value = SetProfilePhotoResult;
817            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
818                f.write_str("a SetProfilePhotoResult struct")
819            }
820            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
821                SetProfilePhotoResult::internal_deserialize(map)
822            }
823        }
824        deserializer.deserialize_struct("SetProfilePhotoResult", SET_PROFILE_PHOTO_RESULT_FIELDS, StructVisitor)
825    }
826}
827
828impl ::serde::ser::Serialize for SetProfilePhotoResult {
829    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
830        // struct serializer
831        use serde::ser::SerializeStruct;
832        let mut s = serializer.serialize_struct("SetProfilePhotoResult", 1)?;
833        self.internal_serialize::<S>(&mut s)?;
834        s.end()
835    }
836}
837
838#[derive(Debug, Clone, PartialEq, Eq)]
839#[non_exhaustive] // variants may be added in the future
840pub enum ThumbnailError {
841    /// Indicates permanent infrastructural failure.
842    PermanentFailure,
843    /// Indicates temporary infrastructural failure.
844    TemporaryFailure,
845    /// Catch-all used for unrecognized values returned from the server. Encountering this value
846    /// typically indicates that this SDK version is out of date.
847    Other,
848}
849
850impl<'de> ::serde::de::Deserialize<'de> for ThumbnailError {
851    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
852        // union deserializer
853        use serde::de::{self, MapAccess, Visitor};
854        struct EnumVisitor;
855        impl<'de> Visitor<'de> for EnumVisitor {
856            type Value = ThumbnailError;
857            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
858                f.write_str("a ThumbnailError structure")
859            }
860            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
861                let tag: &str = match map.next_key()? {
862                    Some(".tag") => map.next_value()?,
863                    _ => return Err(de::Error::missing_field(".tag"))
864                };
865                let value = match tag {
866                    "permanent_failure" => ThumbnailError::PermanentFailure,
867                    "temporary_failure" => ThumbnailError::TemporaryFailure,
868                    _ => ThumbnailError::Other,
869                };
870                crate::eat_json_fields(&mut map)?;
871                Ok(value)
872            }
873        }
874        const VARIANTS: &[&str] = &["permanent_failure",
875                                    "temporary_failure",
876                                    "other"];
877        deserializer.deserialize_struct("ThumbnailError", VARIANTS, EnumVisitor)
878    }
879}
880
881impl ::serde::ser::Serialize for ThumbnailError {
882    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
883        // union serializer
884        use serde::ser::SerializeStruct;
885        match self {
886            ThumbnailError::PermanentFailure => {
887                // unit
888                let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
889                s.serialize_field(".tag", "permanent_failure")?;
890                s.end()
891            }
892            ThumbnailError::TemporaryFailure => {
893                // unit
894                let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
895                s.serialize_field(".tag", "temporary_failure")?;
896                s.end()
897            }
898            ThumbnailError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
899        }
900    }
901}
902
903impl ::std::error::Error for ThumbnailError {
904}
905
906impl ::std::fmt::Display for ThumbnailError {
907    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
908        match self {
909            ThumbnailError::PermanentFailure => f.write_str("Indicates permanent infrastructural failure."),
910            ThumbnailError::TemporaryFailure => f.write_str("Indicates temporary infrastructural failure."),
911            _ => write!(f, "{:?}", *self),
912        }
913    }
914}
915