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
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
// 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,
)]

/// Structured transcript for APIv2
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct ApiStructuredTranscript {
    pub segments: Option<Vec<ApiTranscriptSegment>>,
    pub transcript_locale: String,
}

impl ApiStructuredTranscript {
    pub fn with_segments(mut self, value: Vec<ApiTranscriptSegment>) -> Self {
        self.segments = Some(value);
        self
    }

    pub fn with_transcript_locale(mut self, value: String) -> Self {
        self.transcript_locale = value;
        self
    }
}

const API_STRUCTURED_TRANSCRIPT_FIELDS: &[&str] = &["segments",
                                                    "transcript_locale"];
impl ApiStructuredTranscript {
    // no _opt deserializer
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
    ) -> Result<ApiStructuredTranscript, V::Error> {
        let mut field_segments = None;
        let mut field_transcript_locale = None;
        while let Some(key) = map.next_key::<&str>()? {
            match key {
                "segments" => {
                    if field_segments.is_some() {
                        return Err(::serde::de::Error::duplicate_field("segments"));
                    }
                    field_segments = Some(map.next_value()?);
                }
                "transcript_locale" => {
                    if field_transcript_locale.is_some() {
                        return Err(::serde::de::Error::duplicate_field("transcript_locale"));
                    }
                    field_transcript_locale = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        let result = ApiStructuredTranscript {
            segments: field_segments.and_then(Option::flatten),
            transcript_locale: field_transcript_locale.unwrap_or_default(),
        };
        Ok(result)
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        if let Some(val) = &self.segments {
            s.serialize_field("segments", val)?;
        }
        if !self.transcript_locale.is_empty() {
            s.serialize_field("transcript_locale", &self.transcript_locale)?;
        }
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for ApiStructuredTranscript {
    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 = ApiStructuredTranscript;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a ApiStructuredTranscript struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                ApiStructuredTranscript::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("ApiStructuredTranscript", API_STRUCTURED_TRANSCRIPT_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for ApiStructuredTranscript {
    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("ApiStructuredTranscript", 2)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

/// Transcript segment for APIv2
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct ApiTranscriptSegment {
    pub text: String,
    pub start_time: f64,
    pub end_time: f64,
}

impl ApiTranscriptSegment {
    pub fn with_text(mut self, value: String) -> Self {
        self.text = value;
        self
    }

    pub fn with_start_time(mut self, value: f64) -> Self {
        self.start_time = value;
        self
    }

    pub fn with_end_time(mut self, value: f64) -> Self {
        self.end_time = value;
        self
    }
}

const API_TRANSCRIPT_SEGMENT_FIELDS: &[&str] = &["text",
                                                 "start_time",
                                                 "end_time"];
impl ApiTranscriptSegment {
    // no _opt deserializer
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
    ) -> Result<ApiTranscriptSegment, V::Error> {
        let mut field_text = None;
        let mut field_start_time = None;
        let mut field_end_time = None;
        while let Some(key) = map.next_key::<&str>()? {
            match key {
                "text" => {
                    if field_text.is_some() {
                        return Err(::serde::de::Error::duplicate_field("text"));
                    }
                    field_text = Some(map.next_value()?);
                }
                "start_time" => {
                    if field_start_time.is_some() {
                        return Err(::serde::de::Error::duplicate_field("start_time"));
                    }
                    field_start_time = Some(map.next_value()?);
                }
                "end_time" => {
                    if field_end_time.is_some() {
                        return Err(::serde::de::Error::duplicate_field("end_time"));
                    }
                    field_end_time = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        let result = ApiTranscriptSegment {
            text: field_text.unwrap_or_default(),
            start_time: field_start_time.unwrap_or(0.0),
            end_time: field_end_time.unwrap_or(0.0),
        };
        Ok(result)
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        if !self.text.is_empty() {
            s.serialize_field("text", &self.text)?;
        }
        if self.start_time != 0.0 {
            s.serialize_field("start_time", &self.start_time)?;
        }
        if self.end_time != 0.0 {
            s.serialize_field("end_time", &self.end_time)?;
        }
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for ApiTranscriptSegment {
    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 = ApiTranscriptSegment;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a ApiTranscriptSegment struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                ApiTranscriptSegment::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("ApiTranscriptSegment", API_TRANSCRIPT_SEGMENT_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for ApiTranscriptSegment {
    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("ApiTranscriptSegment", 3)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // variants may be added in the future
pub enum ContentApiV2Error {
    ServerError(String),
    UserError(String),
    MediaDurationError(MediaDurationError),
    NoAudioError,
    LinkDownloadDisabledError,
    SharedLinkPasswordProtected,
    LimitExceededError,
    /// 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 ContentApiV2Error {
    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 = ContentApiV2Error;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a ContentApiV2Error 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 {
                    "server_error" => {
                        match map.next_key()? {
                            Some("server_error") => ContentApiV2Error::ServerError(map.next_value()?),
                            None => return Err(de::Error::missing_field("server_error")),
                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
                        }
                    }
                    "user_error" => {
                        match map.next_key()? {
                            Some("user_error") => ContentApiV2Error::UserError(map.next_value()?),
                            None => return Err(de::Error::missing_field("user_error")),
                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
                        }
                    }
                    "media_duration_error" => ContentApiV2Error::MediaDurationError(MediaDurationError::internal_deserialize(&mut map)?),
                    "no_audio_error" => ContentApiV2Error::NoAudioError,
                    "link_download_disabled_error" => ContentApiV2Error::LinkDownloadDisabledError,
                    "shared_link_password_protected" => ContentApiV2Error::SharedLinkPasswordProtected,
                    "limit_exceeded_error" => ContentApiV2Error::LimitExceededError,
                    _ => ContentApiV2Error::Other,
                };
                crate::eat_json_fields(&mut map)?;
                Ok(value)
            }
        }
        const VARIANTS: &[&str] = &["server_error",
                                    "user_error",
                                    "media_duration_error",
                                    "no_audio_error",
                                    "link_download_disabled_error",
                                    "shared_link_password_protected",
                                    "limit_exceeded_error",
                                    "other"];
        deserializer.deserialize_struct("ContentApiV2Error", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for ContentApiV2Error {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match self {
            ContentApiV2Error::ServerError(x) => {
                // primitive
                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
                s.serialize_field(".tag", "server_error")?;
                s.serialize_field("server_error", x)?;
                s.end()
            }
            ContentApiV2Error::UserError(x) => {
                // primitive
                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
                s.serialize_field(".tag", "user_error")?;
                s.serialize_field("user_error", x)?;
                s.end()
            }
            ContentApiV2Error::MediaDurationError(x) => {
                // struct
                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
                s.serialize_field(".tag", "media_duration_error")?;
                x.internal_serialize::<S>(&mut s)?;
                s.end()
            }
            ContentApiV2Error::NoAudioError => {
                // unit
                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
                s.serialize_field(".tag", "no_audio_error")?;
                s.end()
            }
            ContentApiV2Error::LinkDownloadDisabledError => {
                // unit
                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
                s.serialize_field(".tag", "link_download_disabled_error")?;
                s.end()
            }
            ContentApiV2Error::SharedLinkPasswordProtected => {
                // unit
                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
                s.serialize_field(".tag", "shared_link_password_protected")?;
                s.end()
            }
            ContentApiV2Error::LimitExceededError => {
                // unit
                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
                s.serialize_field(".tag", "limit_exceeded_error")?;
                s.end()
            }
            ContentApiV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

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

impl ::std::fmt::Display for ContentApiV2Error {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match self {
            ContentApiV2Error::ServerError(inner) => write!(f, "server_error: {:?}", inner),
            ContentApiV2Error::UserError(inner) => write!(f, "user_error: {:?}", inner),
            ContentApiV2Error::MediaDurationError(inner) => write!(f, "media_duration_error: {:?}", inner),
            _ => write!(f, "{:?}", *self),
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // variants may be added in the future
pub enum ErrorCode {
    UnknownError,
    /// 400
    BadRequest,
    /// 409
    ApiError,
    /// 403
    AccessError,
    /// 429
    RatelimitError,
    /// 503
    Unavailable,
    /// 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 ErrorCode {
    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 = ErrorCode;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a ErrorCode 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 {
                    "unknown_error" => ErrorCode::UnknownError,
                    "bad_request" => ErrorCode::BadRequest,
                    "api_error" => ErrorCode::ApiError,
                    "access_error" => ErrorCode::AccessError,
                    "ratelimit_error" => ErrorCode::RatelimitError,
                    "unavailable" => ErrorCode::Unavailable,
                    _ => ErrorCode::Other,
                };
                crate::eat_json_fields(&mut map)?;
                Ok(value)
            }
        }
        const VARIANTS: &[&str] = &["unknown_error",
                                    "bad_request",
                                    "api_error",
                                    "access_error",
                                    "ratelimit_error",
                                    "unavailable",
                                    "other"];
        deserializer.deserialize_struct("ErrorCode", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for ErrorCode {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match self {
            ErrorCode::UnknownError => {
                // unit
                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
                s.serialize_field(".tag", "unknown_error")?;
                s.end()
            }
            ErrorCode::BadRequest => {
                // unit
                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
                s.serialize_field(".tag", "bad_request")?;
                s.end()
            }
            ErrorCode::ApiError => {
                // unit
                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
                s.serialize_field(".tag", "api_error")?;
                s.end()
            }
            ErrorCode::AccessError => {
                // unit
                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
                s.serialize_field(".tag", "access_error")?;
                s.end()
            }
            ErrorCode::RatelimitError => {
                // unit
                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
                s.serialize_field(".tag", "ratelimit_error")?;
                s.end()
            }
            ErrorCode::Unavailable => {
                // unit
                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
                s.serialize_field(".tag", "unavailable")?;
                s.end()
            }
            ErrorCode::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // variants may be added in the future
pub enum FileIdOrUrl {
    FileId(String),
    Url(String),
    Path(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 FileIdOrUrl {
    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 = FileIdOrUrl;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a FileIdOrUrl 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_id" => {
                        match map.next_key()? {
                            Some("file_id") => FileIdOrUrl::FileId(map.next_value()?),
                            None => return Err(de::Error::missing_field("file_id")),
                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
                        }
                    }
                    "url" => {
                        match map.next_key()? {
                            Some("url") => FileIdOrUrl::Url(map.next_value()?),
                            None => return Err(de::Error::missing_field("url")),
                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
                        }
                    }
                    "path" => {
                        match map.next_key()? {
                            Some("path") => FileIdOrUrl::Path(map.next_value()?),
                            None => return Err(de::Error::missing_field("path")),
                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
                        }
                    }
                    _ => FileIdOrUrl::Other,
                };
                crate::eat_json_fields(&mut map)?;
                Ok(value)
            }
        }
        const VARIANTS: &[&str] = &["file_id",
                                    "url",
                                    "path",
                                    "other"];
        deserializer.deserialize_struct("FileIdOrUrl", VARIANTS, EnumVisitor)
    }
}

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

/// Arguments for the asynchronous `get_transcript_async` route. Exactly one of `file_id`, `path`,
/// or `url` must be supplied via `file_id_or_url` to identify the audio or video asset to
/// transcribe.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct GetTranscriptArgs {
    /// Identifier of the media asset to transcribe. Callers must set exactly one of the oneof
    /// variants: - file_id: a Dropbox-issued file id (format: "id:<id>") for a file the
    /// authenticated user has access to. - path: an absolute Dropbox path, e.g.
    /// "/folder/recording.mp4". - url: either a Dropbox shared link (www.dropbox.com) or an
    /// external HTTPS URL pointing to a supported audio/video file. - Dropbox shared links are
    /// resolved internally using the caller's authenticated identity and the link's visibility /
    /// download settings. They therefore require an authenticated user context (anonymous `url`
    /// requests against Dropbox links are rejected with an `ACCESS_ERROR`). Links protected by a
    /// password are rejected with `shared_link_password_protected`; links with downloads disabled
    /// are rejected with `link_download_disabled_error`. - External URLs are fetched over HTTPS
    /// through the backend's egress proxy and must point at a supported audio/video file extension.
    /// The referenced asset must be an audio or video file in a supported format; requests against
    /// files with no audio track return a `no_audio_error`.
    pub file_id_or_url: Option<FileIdOrUrl>,
    /// Granularity of the time offsets returned for each transcript segment. Defaults to `SENTENCE.
    /// - SENTENCE: one segment per spoken sentence (recommended). - WORD: one segment per word,
    /// useful for fine-grained alignment such as captioning or highlight-as-you-listen experiences.
    pub timestamp_level: TimestampLevel,
    /// Comma-delimited list of non-lexical filler words to preserve in the transcript output, e.g.
    /// `"uh, ah, uhm"`. By default these fillers are stripped. Unrecognized tokens are ignored.
    /// Leave empty to use the default filtering behavior.
    pub included_special_words: String,
    /// Optional BCP-47 language tag hinting the spoken language of the source audio (e.g. "en-US",
    /// "ja-JP"). When empty, the service auto-detects the language; supplying a hint improves
    /// accuracy and latency for short or ambiguous clips. Unsupported languages fall back to
    /// auto-detection.
    pub audio_language: String,
}

impl Default for GetTranscriptArgs {
    fn default() -> Self {
        GetTranscriptArgs {
            file_id_or_url: None,
            timestamp_level: TimestampLevel::Unknown,
            included_special_words: String::new(),
            audio_language: String::new(),
        }
    }
}

impl GetTranscriptArgs {
    pub fn with_file_id_or_url(mut self, value: FileIdOrUrl) -> Self {
        self.file_id_or_url = Some(value);
        self
    }

    pub fn with_timestamp_level(mut self, value: TimestampLevel) -> Self {
        self.timestamp_level = value;
        self
    }

    pub fn with_included_special_words(mut self, value: String) -> Self {
        self.included_special_words = value;
        self
    }

    pub fn with_audio_language(mut self, value: String) -> Self {
        self.audio_language = value;
        self
    }
}

const GET_TRANSCRIPT_ARGS_FIELDS: &[&str] = &["file_id_or_url",
                                              "timestamp_level",
                                              "included_special_words",
                                              "audio_language"];
impl GetTranscriptArgs {
    // no _opt deserializer
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
    ) -> Result<GetTranscriptArgs, V::Error> {
        let mut field_file_id_or_url = None;
        let mut field_timestamp_level = None;
        let mut field_included_special_words = None;
        let mut field_audio_language = None;
        while let Some(key) = map.next_key::<&str>()? {
            match key {
                "file_id_or_url" => {
                    if field_file_id_or_url.is_some() {
                        return Err(::serde::de::Error::duplicate_field("file_id_or_url"));
                    }
                    field_file_id_or_url = Some(map.next_value()?);
                }
                "timestamp_level" => {
                    if field_timestamp_level.is_some() {
                        return Err(::serde::de::Error::duplicate_field("timestamp_level"));
                    }
                    field_timestamp_level = Some(map.next_value()?);
                }
                "included_special_words" => {
                    if field_included_special_words.is_some() {
                        return Err(::serde::de::Error::duplicate_field("included_special_words"));
                    }
                    field_included_special_words = Some(map.next_value()?);
                }
                "audio_language" => {
                    if field_audio_language.is_some() {
                        return Err(::serde::de::Error::duplicate_field("audio_language"));
                    }
                    field_audio_language = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        let result = GetTranscriptArgs {
            file_id_or_url: field_file_id_or_url.and_then(Option::flatten),
            timestamp_level: field_timestamp_level.unwrap_or(TimestampLevel::Unknown),
            included_special_words: field_included_special_words.unwrap_or_default(),
            audio_language: field_audio_language.unwrap_or_default(),
        };
        Ok(result)
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        if let Some(val) = &self.file_id_or_url {
            s.serialize_field("file_id_or_url", val)?;
        }
        if self.timestamp_level != TimestampLevel::Unknown {
            s.serialize_field("timestamp_level", &self.timestamp_level)?;
        }
        if !self.included_special_words.is_empty() {
            s.serialize_field("included_special_words", &self.included_special_words)?;
        }
        if !self.audio_language.is_empty() {
            s.serialize_field("audio_language", &self.audio_language)?;
        }
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptArgs {
    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 = GetTranscriptArgs;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a GetTranscriptArgs struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                GetTranscriptArgs::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("GetTranscriptArgs", GET_TRANSCRIPT_ARGS_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for GetTranscriptArgs {
    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("GetTranscriptArgs", 4)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

/// Result type for EventBus async check - must end in "CheckResult"
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // variants may be added in the future
pub enum GetTranscriptAsyncCheckResult {
    InProgress,
    Complete(GetTranscriptResult),
    Failed(GetTranscriptAsyncError),
    /// 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 GetTranscriptAsyncCheckResult {
    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 = GetTranscriptAsyncCheckResult;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a GetTranscriptAsyncCheckResult 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 {
                    "in_progress" => GetTranscriptAsyncCheckResult::InProgress,
                    "complete" => GetTranscriptAsyncCheckResult::Complete(GetTranscriptResult::internal_deserialize(&mut map)?),
                    "failed" => GetTranscriptAsyncCheckResult::Failed(GetTranscriptAsyncError::internal_deserialize(&mut map)?),
                    _ => GetTranscriptAsyncCheckResult::Other,
                };
                crate::eat_json_fields(&mut map)?;
                Ok(value)
            }
        }
        const VARIANTS: &[&str] = &["in_progress",
                                    "complete",
                                    "failed",
                                    "other"];
        deserializer.deserialize_struct("GetTranscriptAsyncCheckResult", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for GetTranscriptAsyncCheckResult {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match self {
            GetTranscriptAsyncCheckResult::InProgress => {
                // unit
                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 1)?;
                s.serialize_field(".tag", "in_progress")?;
                s.end()
            }
            GetTranscriptAsyncCheckResult::Complete(x) => {
                // struct
                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 2)?;
                s.serialize_field(".tag", "complete")?;
                x.internal_serialize::<S>(&mut s)?;
                s.end()
            }
            GetTranscriptAsyncCheckResult::Failed(x) => {
                // struct
                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 3)?;
                s.serialize_field(".tag", "failed")?;
                x.internal_serialize::<S>(&mut s)?;
                s.end()
            }
            GetTranscriptAsyncCheckResult::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 GetTranscriptAsyncError {
    pub error_code: ErrorCode,
    pub error_details: Option<ContentApiV2Error>,
}

impl Default for GetTranscriptAsyncError {
    fn default() -> Self {
        GetTranscriptAsyncError {
            error_code: ErrorCode::UnknownError,
            error_details: None,
        }
    }
}

impl GetTranscriptAsyncError {
    pub fn with_error_code(mut self, value: ErrorCode) -> Self {
        self.error_code = value;
        self
    }

    pub fn with_error_details(mut self, value: ContentApiV2Error) -> Self {
        self.error_details = Some(value);
        self
    }
}

const GET_TRANSCRIPT_ASYNC_ERROR_FIELDS: &[&str] = &["error_code",
                                                     "error_details"];
impl GetTranscriptAsyncError {
    // no _opt deserializer
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
    ) -> Result<GetTranscriptAsyncError, V::Error> {
        let mut field_error_code = None;
        let mut field_error_details = None;
        while let Some(key) = map.next_key::<&str>()? {
            match key {
                "error_code" => {
                    if field_error_code.is_some() {
                        return Err(::serde::de::Error::duplicate_field("error_code"));
                    }
                    field_error_code = Some(map.next_value()?);
                }
                "error_details" => {
                    if field_error_details.is_some() {
                        return Err(::serde::de::Error::duplicate_field("error_details"));
                    }
                    field_error_details = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        let result = GetTranscriptAsyncError {
            error_code: field_error_code.unwrap_or(ErrorCode::UnknownError),
            error_details: field_error_details.and_then(Option::flatten),
        };
        Ok(result)
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        if self.error_code != ErrorCode::UnknownError {
            s.serialize_field("error_code", &self.error_code)?;
        }
        if let Some(val) = &self.error_details {
            s.serialize_field("error_details", val)?;
        }
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptAsyncError {
    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 = GetTranscriptAsyncError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a GetTranscriptAsyncError struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                GetTranscriptAsyncError::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("GetTranscriptAsyncError", GET_TRANSCRIPT_ASYNC_ERROR_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for GetTranscriptAsyncError {
    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("GetTranscriptAsyncError", 2)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct GetTranscriptResult {
    /// The structured transcript produced for the requested media asset, with per-segment text,
    /// start/end offsets (in seconds from the beginning of the media), and the detected or
    /// caller-supplied locale.
    pub structured_transcript: Option<ApiStructuredTranscript>,
}

impl GetTranscriptResult {
    pub fn with_structured_transcript(mut self, value: ApiStructuredTranscript) -> Self {
        self.structured_transcript = Some(value);
        self
    }
}

const GET_TRANSCRIPT_RESULT_FIELDS: &[&str] = &["structured_transcript"];
impl GetTranscriptResult {
    // no _opt deserializer
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
    ) -> Result<GetTranscriptResult, V::Error> {
        let mut field_structured_transcript = None;
        while let Some(key) = map.next_key::<&str>()? {
            match key {
                "structured_transcript" => {
                    if field_structured_transcript.is_some() {
                        return Err(::serde::de::Error::duplicate_field("structured_transcript"));
                    }
                    field_structured_transcript = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        let result = GetTranscriptResult {
            structured_transcript: field_structured_transcript.and_then(Option::flatten),
        };
        Ok(result)
    }

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

impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptResult {
    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 = GetTranscriptResult;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a GetTranscriptResult struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                GetTranscriptResult::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("GetTranscriptResult", GET_TRANSCRIPT_RESULT_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for GetTranscriptResult {
    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("GetTranscriptResult", 1)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct MediaDurationError {
    pub limit: i32,
}

impl MediaDurationError {
    pub fn with_limit(mut self, value: i32) -> Self {
        self.limit = value;
        self
    }
}

const MEDIA_DURATION_ERROR_FIELDS: &[&str] = &["limit"];
impl MediaDurationError {
    // no _opt deserializer
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
    ) -> Result<MediaDurationError, V::Error> {
        let mut field_limit = None;
        while let Some(key) = map.next_key::<&str>()? {
            match key {
                "limit" => {
                    if field_limit.is_some() {
                        return Err(::serde::de::Error::duplicate_field("limit"));
                    }
                    field_limit = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        let result = MediaDurationError {
            limit: field_limit.unwrap_or(0),
        };
        Ok(result)
    }

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

impl<'de> ::serde::de::Deserialize<'de> for MediaDurationError {
    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 = MediaDurationError;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a MediaDurationError struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                MediaDurationError::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("MediaDurationError", MEDIA_DURATION_ERROR_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for MediaDurationError {
    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("MediaDurationError", 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 TimestampLevel {
    Unknown,
    Sentence,
    Word,
    /// 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 TimestampLevel {
    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 = TimestampLevel;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a TimestampLevel 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 {
                    "unknown" => TimestampLevel::Unknown,
                    "sentence" => TimestampLevel::Sentence,
                    "word" => TimestampLevel::Word,
                    _ => TimestampLevel::Other,
                };
                crate::eat_json_fields(&mut map)?;
                Ok(value)
            }
        }
        const VARIANTS: &[&str] = &["unknown",
                                    "sentence",
                                    "word",
                                    "other"];
        deserializer.deserialize_struct("TimestampLevel", VARIANTS, EnumVisitor)
    }
}

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