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#[derive(Debug, Clone, PartialEq, Eq)]
341#[non_exhaustive] // variants may be added in the future
342pub enum PhotoSourceArg {
343    /// Image data in base64-encoded bytes.
344    Base64Data(String),
345    /// Catch-all used for unrecognized values returned from the server. Encountering this value
346    /// typically indicates that this SDK version is out of date.
347    Other,
348}
349
350impl<'de> ::serde::de::Deserialize<'de> for PhotoSourceArg {
351    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
352        // union deserializer
353        use serde::de::{self, MapAccess, Visitor};
354        struct EnumVisitor;
355        impl<'de> Visitor<'de> for EnumVisitor {
356            type Value = PhotoSourceArg;
357            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
358                f.write_str("a PhotoSourceArg structure")
359            }
360            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
361                let tag: &str = match map.next_key()? {
362                    Some(".tag") => map.next_value()?,
363                    _ => return Err(de::Error::missing_field(".tag"))
364                };
365                let value = match tag {
366                    "base64_data" => {
367                        match map.next_key()? {
368                            Some("base64_data") => PhotoSourceArg::Base64Data(map.next_value()?),
369                            None => return Err(de::Error::missing_field("base64_data")),
370                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
371                        }
372                    }
373                    _ => PhotoSourceArg::Other,
374                };
375                crate::eat_json_fields(&mut map)?;
376                Ok(value)
377            }
378        }
379        const VARIANTS: &[&str] = &["base64_data",
380                                    "other"];
381        deserializer.deserialize_struct("PhotoSourceArg", VARIANTS, EnumVisitor)
382    }
383}
384
385impl ::serde::ser::Serialize for PhotoSourceArg {
386    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
387        // union serializer
388        use serde::ser::SerializeStruct;
389        match self {
390            PhotoSourceArg::Base64Data(x) => {
391                // primitive
392                let mut s = serializer.serialize_struct("PhotoSourceArg", 2)?;
393                s.serialize_field(".tag", "base64_data")?;
394                s.serialize_field("base64_data", x)?;
395                s.end()
396            }
397            PhotoSourceArg::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
398        }
399    }
400}
401
402#[derive(Debug, Clone, PartialEq, Eq)]
403#[non_exhaustive] // structs may have more fields added in the future.
404pub struct SetProfilePhotoArg {
405    /// Image to set as the user's new profile photo.
406    pub photo: PhotoSourceArg,
407}
408
409impl SetProfilePhotoArg {
410    pub fn new(photo: PhotoSourceArg) -> Self {
411        SetProfilePhotoArg {
412            photo,
413        }
414    }
415}
416
417const SET_PROFILE_PHOTO_ARG_FIELDS: &[&str] = &["photo"];
418impl SetProfilePhotoArg {
419    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
420        map: V,
421    ) -> Result<SetProfilePhotoArg, V::Error> {
422        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
423    }
424
425    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
426        mut map: V,
427        optional: bool,
428    ) -> Result<Option<SetProfilePhotoArg>, V::Error> {
429        let mut field_photo = None;
430        let mut nothing = true;
431        while let Some(key) = map.next_key::<&str>()? {
432            nothing = false;
433            match key {
434                "photo" => {
435                    if field_photo.is_some() {
436                        return Err(::serde::de::Error::duplicate_field("photo"));
437                    }
438                    field_photo = Some(map.next_value()?);
439                }
440                _ => {
441                    // unknown field allowed and ignored
442                    map.next_value::<::serde_json::Value>()?;
443                }
444            }
445        }
446        if optional && nothing {
447            return Ok(None);
448        }
449        let result = SetProfilePhotoArg {
450            photo: field_photo.ok_or_else(|| ::serde::de::Error::missing_field("photo"))?,
451        };
452        Ok(Some(result))
453    }
454
455    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
456        &self,
457        s: &mut S::SerializeStruct,
458    ) -> Result<(), S::Error> {
459        use serde::ser::SerializeStruct;
460        s.serialize_field("photo", &self.photo)?;
461        Ok(())
462    }
463}
464
465impl<'de> ::serde::de::Deserialize<'de> for SetProfilePhotoArg {
466    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
467        // struct deserializer
468        use serde::de::{MapAccess, Visitor};
469        struct StructVisitor;
470        impl<'de> Visitor<'de> for StructVisitor {
471            type Value = SetProfilePhotoArg;
472            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
473                f.write_str("a SetProfilePhotoArg struct")
474            }
475            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
476                SetProfilePhotoArg::internal_deserialize(map)
477            }
478        }
479        deserializer.deserialize_struct("SetProfilePhotoArg", SET_PROFILE_PHOTO_ARG_FIELDS, StructVisitor)
480    }
481}
482
483impl ::serde::ser::Serialize for SetProfilePhotoArg {
484    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
485        // struct serializer
486        use serde::ser::SerializeStruct;
487        let mut s = serializer.serialize_struct("SetProfilePhotoArg", 1)?;
488        self.internal_serialize::<S>(&mut s)?;
489        s.end()
490    }
491}
492
493#[derive(Debug, Clone, PartialEq, Eq)]
494#[non_exhaustive] // variants may be added in the future
495pub enum SetProfilePhotoError {
496    /// File cannot be set as profile photo.
497    FileTypeError,
498    /// File cannot exceed 10 MB.
499    FileSizeError,
500    /// Image must be larger than 128 x 128.
501    DimensionError,
502    /// Image could not be thumbnailed.
503    ThumbnailError,
504    /// Temporary infrastructure failure, please retry.
505    TransientError,
506    /// Catch-all used for unrecognized values returned from the server. Encountering this value
507    /// typically indicates that this SDK version is out of date.
508    Other,
509}
510
511impl<'de> ::serde::de::Deserialize<'de> for SetProfilePhotoError {
512    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
513        // union deserializer
514        use serde::de::{self, MapAccess, Visitor};
515        struct EnumVisitor;
516        impl<'de> Visitor<'de> for EnumVisitor {
517            type Value = SetProfilePhotoError;
518            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
519                f.write_str("a SetProfilePhotoError structure")
520            }
521            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
522                let tag: &str = match map.next_key()? {
523                    Some(".tag") => map.next_value()?,
524                    _ => return Err(de::Error::missing_field(".tag"))
525                };
526                let value = match tag {
527                    "file_type_error" => SetProfilePhotoError::FileTypeError,
528                    "file_size_error" => SetProfilePhotoError::FileSizeError,
529                    "dimension_error" => SetProfilePhotoError::DimensionError,
530                    "thumbnail_error" => SetProfilePhotoError::ThumbnailError,
531                    "transient_error" => SetProfilePhotoError::TransientError,
532                    _ => SetProfilePhotoError::Other,
533                };
534                crate::eat_json_fields(&mut map)?;
535                Ok(value)
536            }
537        }
538        const VARIANTS: &[&str] = &["file_type_error",
539                                    "file_size_error",
540                                    "dimension_error",
541                                    "thumbnail_error",
542                                    "transient_error",
543                                    "other"];
544        deserializer.deserialize_struct("SetProfilePhotoError", VARIANTS, EnumVisitor)
545    }
546}
547
548impl ::serde::ser::Serialize for SetProfilePhotoError {
549    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
550        // union serializer
551        use serde::ser::SerializeStruct;
552        match self {
553            SetProfilePhotoError::FileTypeError => {
554                // unit
555                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
556                s.serialize_field(".tag", "file_type_error")?;
557                s.end()
558            }
559            SetProfilePhotoError::FileSizeError => {
560                // unit
561                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
562                s.serialize_field(".tag", "file_size_error")?;
563                s.end()
564            }
565            SetProfilePhotoError::DimensionError => {
566                // unit
567                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
568                s.serialize_field(".tag", "dimension_error")?;
569                s.end()
570            }
571            SetProfilePhotoError::ThumbnailError => {
572                // unit
573                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
574                s.serialize_field(".tag", "thumbnail_error")?;
575                s.end()
576            }
577            SetProfilePhotoError::TransientError => {
578                // unit
579                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
580                s.serialize_field(".tag", "transient_error")?;
581                s.end()
582            }
583            SetProfilePhotoError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
584        }
585    }
586}
587
588impl ::std::error::Error for SetProfilePhotoError {
589}
590
591impl ::std::fmt::Display for SetProfilePhotoError {
592    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
593        match self {
594            SetProfilePhotoError::FileTypeError => f.write_str("File cannot be set as profile photo."),
595            SetProfilePhotoError::FileSizeError => f.write_str("File cannot exceed 10 MB."),
596            SetProfilePhotoError::DimensionError => f.write_str("Image must be larger than 128 x 128."),
597            SetProfilePhotoError::ThumbnailError => f.write_str("Image could not be thumbnailed."),
598            SetProfilePhotoError::TransientError => f.write_str("Temporary infrastructure failure, please retry."),
599            _ => write!(f, "{:?}", *self),
600        }
601    }
602}
603
604#[derive(Debug, Clone, PartialEq, Eq)]
605#[non_exhaustive] // structs may have more fields added in the future.
606pub struct SetProfilePhotoResult {
607    /// URL for the photo representing the user, if one is set.
608    pub profile_photo_url: String,
609}
610
611impl SetProfilePhotoResult {
612    pub fn new(profile_photo_url: String) -> Self {
613        SetProfilePhotoResult {
614            profile_photo_url,
615        }
616    }
617}
618
619const SET_PROFILE_PHOTO_RESULT_FIELDS: &[&str] = &["profile_photo_url"];
620impl SetProfilePhotoResult {
621    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
622        map: V,
623    ) -> Result<SetProfilePhotoResult, V::Error> {
624        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
625    }
626
627    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
628        mut map: V,
629        optional: bool,
630    ) -> Result<Option<SetProfilePhotoResult>, V::Error> {
631        let mut field_profile_photo_url = None;
632        let mut nothing = true;
633        while let Some(key) = map.next_key::<&str>()? {
634            nothing = false;
635            match key {
636                "profile_photo_url" => {
637                    if field_profile_photo_url.is_some() {
638                        return Err(::serde::de::Error::duplicate_field("profile_photo_url"));
639                    }
640                    field_profile_photo_url = Some(map.next_value()?);
641                }
642                _ => {
643                    // unknown field allowed and ignored
644                    map.next_value::<::serde_json::Value>()?;
645                }
646            }
647        }
648        if optional && nothing {
649            return Ok(None);
650        }
651        let result = SetProfilePhotoResult {
652            profile_photo_url: field_profile_photo_url.ok_or_else(|| ::serde::de::Error::missing_field("profile_photo_url"))?,
653        };
654        Ok(Some(result))
655    }
656
657    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
658        &self,
659        s: &mut S::SerializeStruct,
660    ) -> Result<(), S::Error> {
661        use serde::ser::SerializeStruct;
662        s.serialize_field("profile_photo_url", &self.profile_photo_url)?;
663        Ok(())
664    }
665}
666
667impl<'de> ::serde::de::Deserialize<'de> for SetProfilePhotoResult {
668    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
669        // struct deserializer
670        use serde::de::{MapAccess, Visitor};
671        struct StructVisitor;
672        impl<'de> Visitor<'de> for StructVisitor {
673            type Value = SetProfilePhotoResult;
674            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
675                f.write_str("a SetProfilePhotoResult struct")
676            }
677            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
678                SetProfilePhotoResult::internal_deserialize(map)
679            }
680        }
681        deserializer.deserialize_struct("SetProfilePhotoResult", SET_PROFILE_PHOTO_RESULT_FIELDS, StructVisitor)
682    }
683}
684
685impl ::serde::ser::Serialize for SetProfilePhotoResult {
686    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
687        // struct serializer
688        use serde::ser::SerializeStruct;
689        let mut s = serializer.serialize_struct("SetProfilePhotoResult", 1)?;
690        self.internal_serialize::<S>(&mut s)?;
691        s.end()
692    }
693}
694
695#[derive(Debug, Clone, PartialEq, Eq)]
696#[non_exhaustive] // variants may be added in the future
697pub enum ThumbnailError {
698    /// Indicates permanent infrastructural failure.
699    PermanentFailure,
700    /// Indicates temporary infrastructural failure.
701    TemporaryFailure,
702    /// Catch-all used for unrecognized values returned from the server. Encountering this value
703    /// typically indicates that this SDK version is out of date.
704    Other,
705}
706
707impl<'de> ::serde::de::Deserialize<'de> for ThumbnailError {
708    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
709        // union deserializer
710        use serde::de::{self, MapAccess, Visitor};
711        struct EnumVisitor;
712        impl<'de> Visitor<'de> for EnumVisitor {
713            type Value = ThumbnailError;
714            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
715                f.write_str("a ThumbnailError structure")
716            }
717            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
718                let tag: &str = match map.next_key()? {
719                    Some(".tag") => map.next_value()?,
720                    _ => return Err(de::Error::missing_field(".tag"))
721                };
722                let value = match tag {
723                    "permanent_failure" => ThumbnailError::PermanentFailure,
724                    "temporary_failure" => ThumbnailError::TemporaryFailure,
725                    _ => ThumbnailError::Other,
726                };
727                crate::eat_json_fields(&mut map)?;
728                Ok(value)
729            }
730        }
731        const VARIANTS: &[&str] = &["permanent_failure",
732                                    "temporary_failure",
733                                    "other"];
734        deserializer.deserialize_struct("ThumbnailError", VARIANTS, EnumVisitor)
735    }
736}
737
738impl ::serde::ser::Serialize for ThumbnailError {
739    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
740        // union serializer
741        use serde::ser::SerializeStruct;
742        match self {
743            ThumbnailError::PermanentFailure => {
744                // unit
745                let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
746                s.serialize_field(".tag", "permanent_failure")?;
747                s.end()
748            }
749            ThumbnailError::TemporaryFailure => {
750                // unit
751                let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
752                s.serialize_field(".tag", "temporary_failure")?;
753                s.end()
754            }
755            ThumbnailError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
756        }
757    }
758}
759
760impl ::std::error::Error for ThumbnailError {
761}
762
763impl ::std::fmt::Display for ThumbnailError {
764    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
765        match self {
766            ThumbnailError::PermanentFailure => f.write_str("Indicates permanent infrastructural failure."),
767            ThumbnailError::TemporaryFailure => f.write_str("Indicates temporary infrastructural failure."),
768            _ => write!(f, "{:?}", *self),
769        }
770    }
771}
772