dropbox-sdk 0.20.0

Rust bindings to the Dropbox API, generated by Stone from the official spec.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
// DO NOT EDIT
// This file was @generated by Stone

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

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct AccountPhotoGetArg {
    /// Encoded ID of the user. Must start either with 'dbid:' or 'dbaphid:'.
    pub dbx_account_id: String,
    /// A string representing the size of the photo.
    pub size: String,
    /// True if the photo should be cropped and false otherwise.
    pub circle_crop: bool,
    /// True if we expect account photo to exist.
    pub expect_account_photo: bool,
}

impl AccountPhotoGetArg {
    pub fn new(
        dbx_account_id: String,
        size: String,
        circle_crop: bool,
        expect_account_photo: bool,
    ) -> Self {
        AccountPhotoGetArg {
            dbx_account_id,
            size,
            circle_crop,
            expect_account_photo,
        }
    }
}

const ACCOUNT_PHOTO_GET_ARG_FIELDS: &[&str] = &["dbx_account_id",
                                                "size",
                                                "circle_crop",
                                                "expect_account_photo"];
impl AccountPhotoGetArg {
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        map: V,
    ) -> Result<AccountPhotoGetArg, V::Error> {
        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
    }

    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
        optional: bool,
    ) -> Result<Option<AccountPhotoGetArg>, V::Error> {
        let mut field_dbx_account_id = None;
        let mut field_size = None;
        let mut field_circle_crop = None;
        let mut field_expect_account_photo = None;
        let mut nothing = true;
        while let Some(key) = map.next_key::<&str>()? {
            nothing = false;
            match key {
                "dbx_account_id" => {
                    if field_dbx_account_id.is_some() {
                        return Err(::serde::de::Error::duplicate_field("dbx_account_id"));
                    }
                    field_dbx_account_id = Some(map.next_value()?);
                }
                "size" => {
                    if field_size.is_some() {
                        return Err(::serde::de::Error::duplicate_field("size"));
                    }
                    field_size = Some(map.next_value()?);
                }
                "circle_crop" => {
                    if field_circle_crop.is_some() {
                        return Err(::serde::de::Error::duplicate_field("circle_crop"));
                    }
                    field_circle_crop = Some(map.next_value()?);
                }
                "expect_account_photo" => {
                    if field_expect_account_photo.is_some() {
                        return Err(::serde::de::Error::duplicate_field("expect_account_photo"));
                    }
                    field_expect_account_photo = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        if optional && nothing {
            return Ok(None);
        }
        let result = AccountPhotoGetArg {
            dbx_account_id: field_dbx_account_id.ok_or_else(|| ::serde::de::Error::missing_field("dbx_account_id"))?,
            size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
            circle_crop: field_circle_crop.ok_or_else(|| ::serde::de::Error::missing_field("circle_crop"))?,
            expect_account_photo: field_expect_account_photo.ok_or_else(|| ::serde::de::Error::missing_field("expect_account_photo"))?,
        };
        Ok(Some(result))
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("dbx_account_id", &self.dbx_account_id)?;
        s.serialize_field("size", &self.size)?;
        s.serialize_field("circle_crop", &self.circle_crop)?;
        s.serialize_field("expect_account_photo", &self.expect_account_photo)?;
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for AccountPhotoGetArg {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = AccountPhotoGetArg;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a AccountPhotoGetArg struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                AccountPhotoGetArg::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("AccountPhotoGetArg", ACCOUNT_PHOTO_GET_ARG_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for AccountPhotoGetArg {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("AccountPhotoGetArg", 4)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // variants may be added in the future
pub enum AccountPhotoGetError {
    /// Indicates infrastructural failure.
    ThumbnailError(ThumbnailError),
    /// Account photo is missing (but we did not expect it to exist).
    AccountPhotoMissing,
    /// Account photo was expected to exist, but it's missing.
    ExpectedAccountPhotoMissing,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for AccountPhotoGetError {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = AccountPhotoGetError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a AccountPhotoGetError structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                let value = match tag {
                    "thumbnail_error" => {
                        match map.next_key()? {
                            Some("thumbnail_error") => AccountPhotoGetError::ThumbnailError(map.next_value()?),
                            None => return Err(de::Error::missing_field("thumbnail_error")),
                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
                        }
                    }
                    "account_photo_missing" => AccountPhotoGetError::AccountPhotoMissing,
                    "expected_account_photo_missing" => AccountPhotoGetError::ExpectedAccountPhotoMissing,
                    _ => AccountPhotoGetError::Other,
                };
                crate::eat_json_fields(&mut map)?;
                Ok(value)
            }
        }
        const VARIANTS: &[&str] = &["thumbnail_error",
                                    "account_photo_missing",
                                    "expected_account_photo_missing",
                                    "other"];
        deserializer.deserialize_struct("AccountPhotoGetError", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for AccountPhotoGetError {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match self {
            AccountPhotoGetError::ThumbnailError(x) => {
                // union or polymporphic struct
                let mut s = serializer.serialize_struct("AccountPhotoGetError", 2)?;
                s.serialize_field(".tag", "thumbnail_error")?;
                s.serialize_field("thumbnail_error", x)?;
                s.end()
            }
            AccountPhotoGetError::AccountPhotoMissing => {
                // unit
                let mut s = serializer.serialize_struct("AccountPhotoGetError", 1)?;
                s.serialize_field(".tag", "account_photo_missing")?;
                s.end()
            }
            AccountPhotoGetError::ExpectedAccountPhotoMissing => {
                // unit
                let mut s = serializer.serialize_struct("AccountPhotoGetError", 1)?;
                s.serialize_field(".tag", "expected_account_photo_missing")?;
                s.end()
            }
            AccountPhotoGetError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

impl ::std::error::Error for AccountPhotoGetError {
    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
        match self {
            AccountPhotoGetError::ThumbnailError(inner) => Some(inner),
            _ => None,
        }
    }
}

impl ::std::fmt::Display for AccountPhotoGetError {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            AccountPhotoGetError::ThumbnailError(inner) => write!(f, "Indicates infrastructural failure: {}", inner),
            AccountPhotoGetError::AccountPhotoMissing => f.write_str("Account photo is missing (but we did not expect it to exist)."),
            AccountPhotoGetError::ExpectedAccountPhotoMissing => f.write_str("Account photo was expected to exist, but it's missing."),
            _ => write!(f, "{:?}", *self),
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct AccountPhotoGetResult {
    /// The data returned by get_photo.
    pub content_type: String,
}

impl AccountPhotoGetResult {
    pub fn new(content_type: String) -> Self {
        AccountPhotoGetResult {
            content_type,
        }
    }
}

const ACCOUNT_PHOTO_GET_RESULT_FIELDS: &[&str] = &["content_type"];
impl AccountPhotoGetResult {
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        map: V,
    ) -> Result<AccountPhotoGetResult, V::Error> {
        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
    }

    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
        optional: bool,
    ) -> Result<Option<AccountPhotoGetResult>, V::Error> {
        let mut field_content_type = None;
        let mut nothing = true;
        while let Some(key) = map.next_key::<&str>()? {
            nothing = false;
            match key {
                "content_type" => {
                    if field_content_type.is_some() {
                        return Err(::serde::de::Error::duplicate_field("content_type"));
                    }
                    field_content_type = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        if optional && nothing {
            return Ok(None);
        }
        let result = AccountPhotoGetResult {
            content_type: field_content_type.ok_or_else(|| ::serde::de::Error::missing_field("content_type"))?,
        };
        Ok(Some(result))
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("content_type", &self.content_type)?;
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for AccountPhotoGetResult {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = AccountPhotoGetResult;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a AccountPhotoGetResult struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                AccountPhotoGetResult::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("AccountPhotoGetResult", ACCOUNT_PHOTO_GET_RESULT_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for AccountPhotoGetResult {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("AccountPhotoGetResult", 1)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // variants may be added in the future
pub enum PhotoSourceArg {
    /// Image data in base64-encoded bytes.
    Base64Data(String),
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for PhotoSourceArg {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = PhotoSourceArg;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a PhotoSourceArg structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                let value = match tag {
                    "base64_data" => {
                        match map.next_key()? {
                            Some("base64_data") => PhotoSourceArg::Base64Data(map.next_value()?),
                            None => return Err(de::Error::missing_field("base64_data")),
                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
                        }
                    }
                    _ => PhotoSourceArg::Other,
                };
                crate::eat_json_fields(&mut map)?;
                Ok(value)
            }
        }
        const VARIANTS: &[&str] = &["base64_data",
                                    "other"];
        deserializer.deserialize_struct("PhotoSourceArg", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for PhotoSourceArg {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match self {
            PhotoSourceArg::Base64Data(x) => {
                // primitive
                let mut s = serializer.serialize_struct("PhotoSourceArg", 2)?;
                s.serialize_field(".tag", "base64_data")?;
                s.serialize_field("base64_data", x)?;
                s.end()
            }
            PhotoSourceArg::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct SetProfilePhotoArg {
    /// Image to set as the user's new profile photo.
    pub photo: PhotoSourceArg,
}

impl SetProfilePhotoArg {
    pub fn new(photo: PhotoSourceArg) -> Self {
        SetProfilePhotoArg {
            photo,
        }
    }
}

const SET_PROFILE_PHOTO_ARG_FIELDS: &[&str] = &["photo"];
impl SetProfilePhotoArg {
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        map: V,
    ) -> Result<SetProfilePhotoArg, V::Error> {
        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
    }

    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
        optional: bool,
    ) -> Result<Option<SetProfilePhotoArg>, V::Error> {
        let mut field_photo = None;
        let mut nothing = true;
        while let Some(key) = map.next_key::<&str>()? {
            nothing = false;
            match key {
                "photo" => {
                    if field_photo.is_some() {
                        return Err(::serde::de::Error::duplicate_field("photo"));
                    }
                    field_photo = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        if optional && nothing {
            return Ok(None);
        }
        let result = SetProfilePhotoArg {
            photo: field_photo.ok_or_else(|| ::serde::de::Error::missing_field("photo"))?,
        };
        Ok(Some(result))
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("photo", &self.photo)?;
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for SetProfilePhotoArg {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = SetProfilePhotoArg;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a SetProfilePhotoArg struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                SetProfilePhotoArg::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("SetProfilePhotoArg", SET_PROFILE_PHOTO_ARG_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for SetProfilePhotoArg {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("SetProfilePhotoArg", 1)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // variants may be added in the future
pub enum SetProfilePhotoError {
    /// File cannot be set as profile photo.
    FileTypeError,
    /// File cannot exceed 10 MB.
    FileSizeError,
    /// Image must be larger than 128 x 128.
    DimensionError,
    /// Image could not be thumbnailed.
    ThumbnailError,
    /// Temporary infrastructure failure, please retry.
    TransientError,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for SetProfilePhotoError {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = SetProfilePhotoError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a SetProfilePhotoError structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                let value = match tag {
                    "file_type_error" => SetProfilePhotoError::FileTypeError,
                    "file_size_error" => SetProfilePhotoError::FileSizeError,
                    "dimension_error" => SetProfilePhotoError::DimensionError,
                    "thumbnail_error" => SetProfilePhotoError::ThumbnailError,
                    "transient_error" => SetProfilePhotoError::TransientError,
                    _ => SetProfilePhotoError::Other,
                };
                crate::eat_json_fields(&mut map)?;
                Ok(value)
            }
        }
        const VARIANTS: &[&str] = &["file_type_error",
                                    "file_size_error",
                                    "dimension_error",
                                    "thumbnail_error",
                                    "transient_error",
                                    "other"];
        deserializer.deserialize_struct("SetProfilePhotoError", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for SetProfilePhotoError {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match self {
            SetProfilePhotoError::FileTypeError => {
                // unit
                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
                s.serialize_field(".tag", "file_type_error")?;
                s.end()
            }
            SetProfilePhotoError::FileSizeError => {
                // unit
                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
                s.serialize_field(".tag", "file_size_error")?;
                s.end()
            }
            SetProfilePhotoError::DimensionError => {
                // unit
                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
                s.serialize_field(".tag", "dimension_error")?;
                s.end()
            }
            SetProfilePhotoError::ThumbnailError => {
                // unit
                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
                s.serialize_field(".tag", "thumbnail_error")?;
                s.end()
            }
            SetProfilePhotoError::TransientError => {
                // unit
                let mut s = serializer.serialize_struct("SetProfilePhotoError", 1)?;
                s.serialize_field(".tag", "transient_error")?;
                s.end()
            }
            SetProfilePhotoError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

impl ::std::error::Error for SetProfilePhotoError {
}

impl ::std::fmt::Display for SetProfilePhotoError {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            SetProfilePhotoError::FileTypeError => f.write_str("File cannot be set as profile photo."),
            SetProfilePhotoError::FileSizeError => f.write_str("File cannot exceed 10 MB."),
            SetProfilePhotoError::DimensionError => f.write_str("Image must be larger than 128 x 128."),
            SetProfilePhotoError::ThumbnailError => f.write_str("Image could not be thumbnailed."),
            SetProfilePhotoError::TransientError => f.write_str("Temporary infrastructure failure, please retry."),
            _ => write!(f, "{:?}", *self),
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct SetProfilePhotoResult {
    /// URL for the photo representing the user, if one is set.
    pub profile_photo_url: String,
}

impl SetProfilePhotoResult {
    pub fn new(profile_photo_url: String) -> Self {
        SetProfilePhotoResult {
            profile_photo_url,
        }
    }
}

const SET_PROFILE_PHOTO_RESULT_FIELDS: &[&str] = &["profile_photo_url"];
impl SetProfilePhotoResult {
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        map: V,
    ) -> Result<SetProfilePhotoResult, V::Error> {
        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
    }

    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
        optional: bool,
    ) -> Result<Option<SetProfilePhotoResult>, V::Error> {
        let mut field_profile_photo_url = None;
        let mut nothing = true;
        while let Some(key) = map.next_key::<&str>()? {
            nothing = false;
            match key {
                "profile_photo_url" => {
                    if field_profile_photo_url.is_some() {
                        return Err(::serde::de::Error::duplicate_field("profile_photo_url"));
                    }
                    field_profile_photo_url = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        if optional && nothing {
            return Ok(None);
        }
        let result = SetProfilePhotoResult {
            profile_photo_url: field_profile_photo_url.ok_or_else(|| ::serde::de::Error::missing_field("profile_photo_url"))?,
        };
        Ok(Some(result))
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("profile_photo_url", &self.profile_photo_url)?;
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for SetProfilePhotoResult {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = SetProfilePhotoResult;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a SetProfilePhotoResult struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                SetProfilePhotoResult::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("SetProfilePhotoResult", SET_PROFILE_PHOTO_RESULT_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for SetProfilePhotoResult {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("SetProfilePhotoResult", 1)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // variants may be added in the future
pub enum ThumbnailError {
    /// Indicates permanent infrastructural failure.
    PermanentFailure,
    /// Indicates temporary infrastructural failure.
    TemporaryFailure,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for ThumbnailError {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = ThumbnailError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a ThumbnailError structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                let value = match tag {
                    "permanent_failure" => ThumbnailError::PermanentFailure,
                    "temporary_failure" => ThumbnailError::TemporaryFailure,
                    _ => ThumbnailError::Other,
                };
                crate::eat_json_fields(&mut map)?;
                Ok(value)
            }
        }
        const VARIANTS: &[&str] = &["permanent_failure",
                                    "temporary_failure",
                                    "other"];
        deserializer.deserialize_struct("ThumbnailError", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for ThumbnailError {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match self {
            ThumbnailError::PermanentFailure => {
                // unit
                let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
                s.serialize_field(".tag", "permanent_failure")?;
                s.end()
            }
            ThumbnailError::TemporaryFailure => {
                // unit
                let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
                s.serialize_field(".tag", "temporary_failure")?;
                s.end()
            }
            ThumbnailError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

impl ::std::error::Error for ThumbnailError {
}

impl ::std::fmt::Display for ThumbnailError {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            ThumbnailError::PermanentFailure => f.write_str("Indicates permanent infrastructural failure."),
            ThumbnailError::TemporaryFailure => f.write_str("Indicates temporary infrastructural failure."),
            _ => write!(f, "{:?}", *self),
        }
    }
}