Skip to main content

dropbox_sdk/generated/types/
riviera.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/// GPS coordinates and related tags extracted from image EXIF data. Fields are populated on a
13/// best-effort basis and may be empty when absent from the source file.
14#[derive(Debug, Clone, PartialEq, Default)]
15#[non_exhaustive] // structs may have more fields added in the future.
16pub struct ApiExifGpsMetadata {
17    /// Latitude / longitude in decimal degrees (positive = N/E, negative = S/W).
18    pub latitude: f32,
19    pub longitude: f32,
20    /// Altitude in meters, as reported by the source (string to preserve the original
21    /// representation, which may include a reference direction).
22    pub altitude: String,
23    /// Timestamp / datestamp of the GPS fix, in the EXIF-provided format.
24    pub timestamp: String,
25    pub datestamp: String,
26}
27
28impl ApiExifGpsMetadata {
29    pub fn with_latitude(mut self, value: f32) -> Self {
30        self.latitude = value;
31        self
32    }
33
34    pub fn with_longitude(mut self, value: f32) -> Self {
35        self.longitude = value;
36        self
37    }
38
39    pub fn with_altitude(mut self, value: String) -> Self {
40        self.altitude = value;
41        self
42    }
43
44    pub fn with_timestamp(mut self, value: String) -> Self {
45        self.timestamp = value;
46        self
47    }
48
49    pub fn with_datestamp(mut self, value: String) -> Self {
50        self.datestamp = value;
51        self
52    }
53}
54
55const API_EXIF_GPS_METADATA_FIELDS: &[&str] = &["latitude",
56                                                "longitude",
57                                                "altitude",
58                                                "timestamp",
59                                                "datestamp"];
60impl ApiExifGpsMetadata {
61    // no _opt deserializer
62    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
63        mut map: V,
64    ) -> Result<ApiExifGpsMetadata, V::Error> {
65        let mut field_latitude = None;
66        let mut field_longitude = None;
67        let mut field_altitude = None;
68        let mut field_timestamp = None;
69        let mut field_datestamp = None;
70        while let Some(key) = map.next_key::<&str>()? {
71            match key {
72                "latitude" => {
73                    if field_latitude.is_some() {
74                        return Err(::serde::de::Error::duplicate_field("latitude"));
75                    }
76                    field_latitude = Some(map.next_value()?);
77                }
78                "longitude" => {
79                    if field_longitude.is_some() {
80                        return Err(::serde::de::Error::duplicate_field("longitude"));
81                    }
82                    field_longitude = Some(map.next_value()?);
83                }
84                "altitude" => {
85                    if field_altitude.is_some() {
86                        return Err(::serde::de::Error::duplicate_field("altitude"));
87                    }
88                    field_altitude = Some(map.next_value()?);
89                }
90                "timestamp" => {
91                    if field_timestamp.is_some() {
92                        return Err(::serde::de::Error::duplicate_field("timestamp"));
93                    }
94                    field_timestamp = Some(map.next_value()?);
95                }
96                "datestamp" => {
97                    if field_datestamp.is_some() {
98                        return Err(::serde::de::Error::duplicate_field("datestamp"));
99                    }
100                    field_datestamp = Some(map.next_value()?);
101                }
102                _ => {
103                    // unknown field allowed and ignored
104                    map.next_value::<::serde_json::Value>()?;
105                }
106            }
107        }
108        let result = ApiExifGpsMetadata {
109            latitude: field_latitude.unwrap_or(0.0),
110            longitude: field_longitude.unwrap_or(0.0),
111            altitude: field_altitude.unwrap_or_default(),
112            timestamp: field_timestamp.unwrap_or_default(),
113            datestamp: field_datestamp.unwrap_or_default(),
114        };
115        Ok(result)
116    }
117
118    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
119        &self,
120        s: &mut S::SerializeStruct,
121    ) -> Result<(), S::Error> {
122        use serde::ser::SerializeStruct;
123        if self.latitude != 0.0 {
124            s.serialize_field("latitude", &self.latitude)?;
125        }
126        if self.longitude != 0.0 {
127            s.serialize_field("longitude", &self.longitude)?;
128        }
129        if !self.altitude.is_empty() {
130            s.serialize_field("altitude", &self.altitude)?;
131        }
132        if !self.timestamp.is_empty() {
133            s.serialize_field("timestamp", &self.timestamp)?;
134        }
135        if !self.datestamp.is_empty() {
136            s.serialize_field("datestamp", &self.datestamp)?;
137        }
138        Ok(())
139    }
140}
141
142impl<'de> ::serde::de::Deserialize<'de> for ApiExifGpsMetadata {
143    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
144        // struct deserializer
145        use serde::de::{MapAccess, Visitor};
146        struct StructVisitor;
147        impl<'de> Visitor<'de> for StructVisitor {
148            type Value = ApiExifGpsMetadata;
149            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
150                f.write_str("a ApiExifGpsMetadata struct")
151            }
152            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
153                ApiExifGpsMetadata::internal_deserialize(map)
154            }
155        }
156        deserializer.deserialize_struct("ApiExifGpsMetadata", API_EXIF_GPS_METADATA_FIELDS, StructVisitor)
157    }
158}
159
160impl ::serde::ser::Serialize for ApiExifGpsMetadata {
161    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
162        // struct serializer
163        use serde::ser::SerializeStruct;
164        let mut s = serializer.serialize_struct("ApiExifGpsMetadata", 5)?;
165        self.internal_serialize::<S>(&mut s)?;
166        s.end()
167    }
168}
169
170/// Image EXIF metadata. Mirrors the useful subset of the internal `riviera.ExifMetadata` message.
171/// Fields are best-effort and may be empty.
172#[derive(Debug, Clone, PartialEq, Default)]
173#[non_exhaustive] // structs may have more fields added in the future.
174pub struct ApiExifMetadata {
175    pub image_width: u32,
176    pub image_height: u32,
177    pub camera_make: String,
178    pub camera_model: String,
179    pub lens_model: String,
180    /// Capture time in the EXIF-provided format (local time of the camera).
181    pub date_time_original: String,
182    /// Timezone offset for `date_time_original`, e.g. "+09:00".
183    pub offset_time_original: String,
184    /// EXIF orientation value (1-8). See the EXIF spec; 1 is the normal upright orientation.
185    pub orientation: u32,
186    /// fraction in string form, e.g. "1/250"
187    pub exposure_time: String,
188    pub aperture_value: f64,
189    pub iso_speed: u32,
190    /// e.g. "26.0 mm"
191    pub focal_length: String,
192    pub megapixels: f64,
193    pub artist: String,
194    pub copyright: String,
195    pub gps_metadata: Option<ApiExifGpsMetadata>,
196}
197
198impl ApiExifMetadata {
199    pub fn with_image_width(mut self, value: u32) -> Self {
200        self.image_width = value;
201        self
202    }
203
204    pub fn with_image_height(mut self, value: u32) -> Self {
205        self.image_height = value;
206        self
207    }
208
209    pub fn with_camera_make(mut self, value: String) -> Self {
210        self.camera_make = value;
211        self
212    }
213
214    pub fn with_camera_model(mut self, value: String) -> Self {
215        self.camera_model = value;
216        self
217    }
218
219    pub fn with_lens_model(mut self, value: String) -> Self {
220        self.lens_model = value;
221        self
222    }
223
224    pub fn with_date_time_original(mut self, value: String) -> Self {
225        self.date_time_original = value;
226        self
227    }
228
229    pub fn with_offset_time_original(mut self, value: String) -> Self {
230        self.offset_time_original = value;
231        self
232    }
233
234    pub fn with_orientation(mut self, value: u32) -> Self {
235        self.orientation = value;
236        self
237    }
238
239    pub fn with_exposure_time(mut self, value: String) -> Self {
240        self.exposure_time = value;
241        self
242    }
243
244    pub fn with_aperture_value(mut self, value: f64) -> Self {
245        self.aperture_value = value;
246        self
247    }
248
249    pub fn with_iso_speed(mut self, value: u32) -> Self {
250        self.iso_speed = value;
251        self
252    }
253
254    pub fn with_focal_length(mut self, value: String) -> Self {
255        self.focal_length = value;
256        self
257    }
258
259    pub fn with_megapixels(mut self, value: f64) -> Self {
260        self.megapixels = value;
261        self
262    }
263
264    pub fn with_artist(mut self, value: String) -> Self {
265        self.artist = value;
266        self
267    }
268
269    pub fn with_copyright(mut self, value: String) -> Self {
270        self.copyright = value;
271        self
272    }
273
274    pub fn with_gps_metadata(mut self, value: ApiExifGpsMetadata) -> Self {
275        self.gps_metadata = Some(value);
276        self
277    }
278}
279
280const API_EXIF_METADATA_FIELDS: &[&str] = &["image_width",
281                                            "image_height",
282                                            "camera_make",
283                                            "camera_model",
284                                            "lens_model",
285                                            "date_time_original",
286                                            "offset_time_original",
287                                            "orientation",
288                                            "exposure_time",
289                                            "aperture_value",
290                                            "iso_speed",
291                                            "focal_length",
292                                            "megapixels",
293                                            "artist",
294                                            "copyright",
295                                            "gps_metadata"];
296impl ApiExifMetadata {
297    // no _opt deserializer
298    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
299        mut map: V,
300    ) -> Result<ApiExifMetadata, V::Error> {
301        let mut field_image_width = None;
302        let mut field_image_height = None;
303        let mut field_camera_make = None;
304        let mut field_camera_model = None;
305        let mut field_lens_model = None;
306        let mut field_date_time_original = None;
307        let mut field_offset_time_original = None;
308        let mut field_orientation = None;
309        let mut field_exposure_time = None;
310        let mut field_aperture_value = None;
311        let mut field_iso_speed = None;
312        let mut field_focal_length = None;
313        let mut field_megapixels = None;
314        let mut field_artist = None;
315        let mut field_copyright = None;
316        let mut field_gps_metadata = None;
317        while let Some(key) = map.next_key::<&str>()? {
318            match key {
319                "image_width" => {
320                    if field_image_width.is_some() {
321                        return Err(::serde::de::Error::duplicate_field("image_width"));
322                    }
323                    field_image_width = Some(map.next_value()?);
324                }
325                "image_height" => {
326                    if field_image_height.is_some() {
327                        return Err(::serde::de::Error::duplicate_field("image_height"));
328                    }
329                    field_image_height = Some(map.next_value()?);
330                }
331                "camera_make" => {
332                    if field_camera_make.is_some() {
333                        return Err(::serde::de::Error::duplicate_field("camera_make"));
334                    }
335                    field_camera_make = Some(map.next_value()?);
336                }
337                "camera_model" => {
338                    if field_camera_model.is_some() {
339                        return Err(::serde::de::Error::duplicate_field("camera_model"));
340                    }
341                    field_camera_model = Some(map.next_value()?);
342                }
343                "lens_model" => {
344                    if field_lens_model.is_some() {
345                        return Err(::serde::de::Error::duplicate_field("lens_model"));
346                    }
347                    field_lens_model = Some(map.next_value()?);
348                }
349                "date_time_original" => {
350                    if field_date_time_original.is_some() {
351                        return Err(::serde::de::Error::duplicate_field("date_time_original"));
352                    }
353                    field_date_time_original = Some(map.next_value()?);
354                }
355                "offset_time_original" => {
356                    if field_offset_time_original.is_some() {
357                        return Err(::serde::de::Error::duplicate_field("offset_time_original"));
358                    }
359                    field_offset_time_original = Some(map.next_value()?);
360                }
361                "orientation" => {
362                    if field_orientation.is_some() {
363                        return Err(::serde::de::Error::duplicate_field("orientation"));
364                    }
365                    field_orientation = Some(map.next_value()?);
366                }
367                "exposure_time" => {
368                    if field_exposure_time.is_some() {
369                        return Err(::serde::de::Error::duplicate_field("exposure_time"));
370                    }
371                    field_exposure_time = Some(map.next_value()?);
372                }
373                "aperture_value" => {
374                    if field_aperture_value.is_some() {
375                        return Err(::serde::de::Error::duplicate_field("aperture_value"));
376                    }
377                    field_aperture_value = Some(map.next_value()?);
378                }
379                "iso_speed" => {
380                    if field_iso_speed.is_some() {
381                        return Err(::serde::de::Error::duplicate_field("iso_speed"));
382                    }
383                    field_iso_speed = Some(map.next_value()?);
384                }
385                "focal_length" => {
386                    if field_focal_length.is_some() {
387                        return Err(::serde::de::Error::duplicate_field("focal_length"));
388                    }
389                    field_focal_length = Some(map.next_value()?);
390                }
391                "megapixels" => {
392                    if field_megapixels.is_some() {
393                        return Err(::serde::de::Error::duplicate_field("megapixels"));
394                    }
395                    field_megapixels = Some(map.next_value()?);
396                }
397                "artist" => {
398                    if field_artist.is_some() {
399                        return Err(::serde::de::Error::duplicate_field("artist"));
400                    }
401                    field_artist = Some(map.next_value()?);
402                }
403                "copyright" => {
404                    if field_copyright.is_some() {
405                        return Err(::serde::de::Error::duplicate_field("copyright"));
406                    }
407                    field_copyright = Some(map.next_value()?);
408                }
409                "gps_metadata" => {
410                    if field_gps_metadata.is_some() {
411                        return Err(::serde::de::Error::duplicate_field("gps_metadata"));
412                    }
413                    field_gps_metadata = Some(map.next_value()?);
414                }
415                _ => {
416                    // unknown field allowed and ignored
417                    map.next_value::<::serde_json::Value>()?;
418                }
419            }
420        }
421        let result = ApiExifMetadata {
422            image_width: field_image_width.unwrap_or(0),
423            image_height: field_image_height.unwrap_or(0),
424            camera_make: field_camera_make.unwrap_or_default(),
425            camera_model: field_camera_model.unwrap_or_default(),
426            lens_model: field_lens_model.unwrap_or_default(),
427            date_time_original: field_date_time_original.unwrap_or_default(),
428            offset_time_original: field_offset_time_original.unwrap_or_default(),
429            orientation: field_orientation.unwrap_or(0),
430            exposure_time: field_exposure_time.unwrap_or_default(),
431            aperture_value: field_aperture_value.unwrap_or(0.0),
432            iso_speed: field_iso_speed.unwrap_or(0),
433            focal_length: field_focal_length.unwrap_or_default(),
434            megapixels: field_megapixels.unwrap_or(0.0),
435            artist: field_artist.unwrap_or_default(),
436            copyright: field_copyright.unwrap_or_default(),
437            gps_metadata: field_gps_metadata.and_then(Option::flatten),
438        };
439        Ok(result)
440    }
441
442    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
443        &self,
444        s: &mut S::SerializeStruct,
445    ) -> Result<(), S::Error> {
446        use serde::ser::SerializeStruct;
447        if self.image_width != 0 {
448            s.serialize_field("image_width", &self.image_width)?;
449        }
450        if self.image_height != 0 {
451            s.serialize_field("image_height", &self.image_height)?;
452        }
453        if !self.camera_make.is_empty() {
454            s.serialize_field("camera_make", &self.camera_make)?;
455        }
456        if !self.camera_model.is_empty() {
457            s.serialize_field("camera_model", &self.camera_model)?;
458        }
459        if !self.lens_model.is_empty() {
460            s.serialize_field("lens_model", &self.lens_model)?;
461        }
462        if !self.date_time_original.is_empty() {
463            s.serialize_field("date_time_original", &self.date_time_original)?;
464        }
465        if !self.offset_time_original.is_empty() {
466            s.serialize_field("offset_time_original", &self.offset_time_original)?;
467        }
468        if self.orientation != 0 {
469            s.serialize_field("orientation", &self.orientation)?;
470        }
471        if !self.exposure_time.is_empty() {
472            s.serialize_field("exposure_time", &self.exposure_time)?;
473        }
474        if self.aperture_value != 0.0 {
475            s.serialize_field("aperture_value", &self.aperture_value)?;
476        }
477        if self.iso_speed != 0 {
478            s.serialize_field("iso_speed", &self.iso_speed)?;
479        }
480        if !self.focal_length.is_empty() {
481            s.serialize_field("focal_length", &self.focal_length)?;
482        }
483        if self.megapixels != 0.0 {
484            s.serialize_field("megapixels", &self.megapixels)?;
485        }
486        if !self.artist.is_empty() {
487            s.serialize_field("artist", &self.artist)?;
488        }
489        if !self.copyright.is_empty() {
490            s.serialize_field("copyright", &self.copyright)?;
491        }
492        if let Some(val) = &self.gps_metadata {
493            s.serialize_field("gps_metadata", val)?;
494        }
495        Ok(())
496    }
497}
498
499impl<'de> ::serde::de::Deserialize<'de> for ApiExifMetadata {
500    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
501        // struct deserializer
502        use serde::de::{MapAccess, Visitor};
503        struct StructVisitor;
504        impl<'de> Visitor<'de> for StructVisitor {
505            type Value = ApiExifMetadata;
506            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
507                f.write_str("a ApiExifMetadata struct")
508            }
509            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
510                ApiExifMetadata::internal_deserialize(map)
511            }
512        }
513        deserializer.deserialize_struct("ApiExifMetadata", API_EXIF_METADATA_FIELDS, StructVisitor)
514    }
515}
516
517impl ::serde::ser::Serialize for ApiExifMetadata {
518    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
519        // struct serializer
520        use serde::ser::SerializeStruct;
521        let mut s = serializer.serialize_struct("ApiExifMetadata", 16)?;
522        self.internal_serialize::<S>(&mut s)?;
523        s.end()
524    }
525}
526
527/// Audio/video container and per-stream metadata. Mirrors the useful subset of the internal
528/// `riviera.MediaMetadata` message.
529#[derive(Debug, Clone, PartialEq, Default)]
530#[non_exhaustive] // structs may have more fields added in the future.
531pub struct ApiMediaMetadata {
532    pub bitrate_bps: u64,
533    pub duration_s: f64,
534    /// Container-level creation time, when present.
535    pub creation_time: String,
536    pub streams: Option<Vec<ApiMediaStream>>,
537}
538
539impl ApiMediaMetadata {
540    pub fn with_bitrate_bps(mut self, value: u64) -> Self {
541        self.bitrate_bps = value;
542        self
543    }
544
545    pub fn with_duration_s(mut self, value: f64) -> Self {
546        self.duration_s = value;
547        self
548    }
549
550    pub fn with_creation_time(mut self, value: String) -> Self {
551        self.creation_time = value;
552        self
553    }
554
555    pub fn with_streams(mut self, value: Vec<ApiMediaStream>) -> Self {
556        self.streams = Some(value);
557        self
558    }
559}
560
561const API_MEDIA_METADATA_FIELDS: &[&str] = &["bitrate_bps",
562                                             "duration_s",
563                                             "creation_time",
564                                             "streams"];
565impl ApiMediaMetadata {
566    // no _opt deserializer
567    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
568        mut map: V,
569    ) -> Result<ApiMediaMetadata, V::Error> {
570        let mut field_bitrate_bps = None;
571        let mut field_duration_s = None;
572        let mut field_creation_time = None;
573        let mut field_streams = None;
574        while let Some(key) = map.next_key::<&str>()? {
575            match key {
576                "bitrate_bps" => {
577                    if field_bitrate_bps.is_some() {
578                        return Err(::serde::de::Error::duplicate_field("bitrate_bps"));
579                    }
580                    field_bitrate_bps = Some(map.next_value()?);
581                }
582                "duration_s" => {
583                    if field_duration_s.is_some() {
584                        return Err(::serde::de::Error::duplicate_field("duration_s"));
585                    }
586                    field_duration_s = Some(map.next_value()?);
587                }
588                "creation_time" => {
589                    if field_creation_time.is_some() {
590                        return Err(::serde::de::Error::duplicate_field("creation_time"));
591                    }
592                    field_creation_time = Some(map.next_value()?);
593                }
594                "streams" => {
595                    if field_streams.is_some() {
596                        return Err(::serde::de::Error::duplicate_field("streams"));
597                    }
598                    field_streams = Some(map.next_value()?);
599                }
600                _ => {
601                    // unknown field allowed and ignored
602                    map.next_value::<::serde_json::Value>()?;
603                }
604            }
605        }
606        let result = ApiMediaMetadata {
607            bitrate_bps: field_bitrate_bps.unwrap_or(0),
608            duration_s: field_duration_s.unwrap_or(0.0),
609            creation_time: field_creation_time.unwrap_or_default(),
610            streams: field_streams.and_then(Option::flatten),
611        };
612        Ok(result)
613    }
614
615    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
616        &self,
617        s: &mut S::SerializeStruct,
618    ) -> Result<(), S::Error> {
619        use serde::ser::SerializeStruct;
620        if self.bitrate_bps != 0 {
621            s.serialize_field("bitrate_bps", &self.bitrate_bps)?;
622        }
623        if self.duration_s != 0.0 {
624            s.serialize_field("duration_s", &self.duration_s)?;
625        }
626        if !self.creation_time.is_empty() {
627            s.serialize_field("creation_time", &self.creation_time)?;
628        }
629        if let Some(val) = &self.streams {
630            s.serialize_field("streams", val)?;
631        }
632        Ok(())
633    }
634}
635
636impl<'de> ::serde::de::Deserialize<'de> for ApiMediaMetadata {
637    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
638        // struct deserializer
639        use serde::de::{MapAccess, Visitor};
640        struct StructVisitor;
641        impl<'de> Visitor<'de> for StructVisitor {
642            type Value = ApiMediaMetadata;
643            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
644                f.write_str("a ApiMediaMetadata struct")
645            }
646            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
647                ApiMediaMetadata::internal_deserialize(map)
648            }
649        }
650        deserializer.deserialize_struct("ApiMediaMetadata", API_MEDIA_METADATA_FIELDS, StructVisitor)
651    }
652}
653
654impl ::serde::ser::Serialize for ApiMediaMetadata {
655    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
656        // struct serializer
657        use serde::ser::SerializeStruct;
658        let mut s = serializer.serialize_struct("ApiMediaMetadata", 4)?;
659        self.internal_serialize::<S>(&mut s)?;
660        s.end()
661    }
662}
663
664/// A single audio or video stream within a media file.
665#[derive(Debug, Clone, PartialEq, Default)]
666#[non_exhaustive] // structs may have more fields added in the future.
667pub struct ApiMediaStream {
668    pub index: u32,
669    /// "audio", "video", etc.
670    pub codec_type: String,
671    pub codec_name: String,
672    pub bitrate_bps: u64,
673    pub duration_s: f64,
674    /// Video-specific fields (zero / empty for audio streams).
675    pub width: u32,
676    pub height: u32,
677    pub frames_per_second: f64,
678    pub rotation: i32,
679    /// e.g. "16:9"
680    pub display_aspect_ratio: String,
681    /// Audio-specific fields (zero / empty for video streams).
682    pub channels: u32,
683    pub channel_layout: String,
684    pub sample_rate_s: u64,
685    /// ISO 639 language code for the stream, when present.
686    pub language_iso_639: String,
687}
688
689impl ApiMediaStream {
690    pub fn with_index(mut self, value: u32) -> Self {
691        self.index = value;
692        self
693    }
694
695    pub fn with_codec_type(mut self, value: String) -> Self {
696        self.codec_type = value;
697        self
698    }
699
700    pub fn with_codec_name(mut self, value: String) -> Self {
701        self.codec_name = value;
702        self
703    }
704
705    pub fn with_bitrate_bps(mut self, value: u64) -> Self {
706        self.bitrate_bps = value;
707        self
708    }
709
710    pub fn with_duration_s(mut self, value: f64) -> Self {
711        self.duration_s = value;
712        self
713    }
714
715    pub fn with_width(mut self, value: u32) -> Self {
716        self.width = value;
717        self
718    }
719
720    pub fn with_height(mut self, value: u32) -> Self {
721        self.height = value;
722        self
723    }
724
725    pub fn with_frames_per_second(mut self, value: f64) -> Self {
726        self.frames_per_second = value;
727        self
728    }
729
730    pub fn with_rotation(mut self, value: i32) -> Self {
731        self.rotation = value;
732        self
733    }
734
735    pub fn with_display_aspect_ratio(mut self, value: String) -> Self {
736        self.display_aspect_ratio = value;
737        self
738    }
739
740    pub fn with_channels(mut self, value: u32) -> Self {
741        self.channels = value;
742        self
743    }
744
745    pub fn with_channel_layout(mut self, value: String) -> Self {
746        self.channel_layout = value;
747        self
748    }
749
750    pub fn with_sample_rate_s(mut self, value: u64) -> Self {
751        self.sample_rate_s = value;
752        self
753    }
754
755    pub fn with_language_iso_639(mut self, value: String) -> Self {
756        self.language_iso_639 = value;
757        self
758    }
759}
760
761const API_MEDIA_STREAM_FIELDS: &[&str] = &["index",
762                                           "codec_type",
763                                           "codec_name",
764                                           "bitrate_bps",
765                                           "duration_s",
766                                           "width",
767                                           "height",
768                                           "frames_per_second",
769                                           "rotation",
770                                           "display_aspect_ratio",
771                                           "channels",
772                                           "channel_layout",
773                                           "sample_rate_s",
774                                           "language_iso_639"];
775impl ApiMediaStream {
776    // no _opt deserializer
777    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
778        mut map: V,
779    ) -> Result<ApiMediaStream, V::Error> {
780        let mut field_index = None;
781        let mut field_codec_type = None;
782        let mut field_codec_name = None;
783        let mut field_bitrate_bps = None;
784        let mut field_duration_s = None;
785        let mut field_width = None;
786        let mut field_height = None;
787        let mut field_frames_per_second = None;
788        let mut field_rotation = None;
789        let mut field_display_aspect_ratio = None;
790        let mut field_channels = None;
791        let mut field_channel_layout = None;
792        let mut field_sample_rate_s = None;
793        let mut field_language_iso_639 = None;
794        while let Some(key) = map.next_key::<&str>()? {
795            match key {
796                "index" => {
797                    if field_index.is_some() {
798                        return Err(::serde::de::Error::duplicate_field("index"));
799                    }
800                    field_index = Some(map.next_value()?);
801                }
802                "codec_type" => {
803                    if field_codec_type.is_some() {
804                        return Err(::serde::de::Error::duplicate_field("codec_type"));
805                    }
806                    field_codec_type = Some(map.next_value()?);
807                }
808                "codec_name" => {
809                    if field_codec_name.is_some() {
810                        return Err(::serde::de::Error::duplicate_field("codec_name"));
811                    }
812                    field_codec_name = Some(map.next_value()?);
813                }
814                "bitrate_bps" => {
815                    if field_bitrate_bps.is_some() {
816                        return Err(::serde::de::Error::duplicate_field("bitrate_bps"));
817                    }
818                    field_bitrate_bps = Some(map.next_value()?);
819                }
820                "duration_s" => {
821                    if field_duration_s.is_some() {
822                        return Err(::serde::de::Error::duplicate_field("duration_s"));
823                    }
824                    field_duration_s = Some(map.next_value()?);
825                }
826                "width" => {
827                    if field_width.is_some() {
828                        return Err(::serde::de::Error::duplicate_field("width"));
829                    }
830                    field_width = Some(map.next_value()?);
831                }
832                "height" => {
833                    if field_height.is_some() {
834                        return Err(::serde::de::Error::duplicate_field("height"));
835                    }
836                    field_height = Some(map.next_value()?);
837                }
838                "frames_per_second" => {
839                    if field_frames_per_second.is_some() {
840                        return Err(::serde::de::Error::duplicate_field("frames_per_second"));
841                    }
842                    field_frames_per_second = Some(map.next_value()?);
843                }
844                "rotation" => {
845                    if field_rotation.is_some() {
846                        return Err(::serde::de::Error::duplicate_field("rotation"));
847                    }
848                    field_rotation = Some(map.next_value()?);
849                }
850                "display_aspect_ratio" => {
851                    if field_display_aspect_ratio.is_some() {
852                        return Err(::serde::de::Error::duplicate_field("display_aspect_ratio"));
853                    }
854                    field_display_aspect_ratio = Some(map.next_value()?);
855                }
856                "channels" => {
857                    if field_channels.is_some() {
858                        return Err(::serde::de::Error::duplicate_field("channels"));
859                    }
860                    field_channels = Some(map.next_value()?);
861                }
862                "channel_layout" => {
863                    if field_channel_layout.is_some() {
864                        return Err(::serde::de::Error::duplicate_field("channel_layout"));
865                    }
866                    field_channel_layout = Some(map.next_value()?);
867                }
868                "sample_rate_s" => {
869                    if field_sample_rate_s.is_some() {
870                        return Err(::serde::de::Error::duplicate_field("sample_rate_s"));
871                    }
872                    field_sample_rate_s = Some(map.next_value()?);
873                }
874                "language_iso_639" => {
875                    if field_language_iso_639.is_some() {
876                        return Err(::serde::de::Error::duplicate_field("language_iso_639"));
877                    }
878                    field_language_iso_639 = Some(map.next_value()?);
879                }
880                _ => {
881                    // unknown field allowed and ignored
882                    map.next_value::<::serde_json::Value>()?;
883                }
884            }
885        }
886        let result = ApiMediaStream {
887            index: field_index.unwrap_or(0),
888            codec_type: field_codec_type.unwrap_or_default(),
889            codec_name: field_codec_name.unwrap_or_default(),
890            bitrate_bps: field_bitrate_bps.unwrap_or(0),
891            duration_s: field_duration_s.unwrap_or(0.0),
892            width: field_width.unwrap_or(0),
893            height: field_height.unwrap_or(0),
894            frames_per_second: field_frames_per_second.unwrap_or(0.0),
895            rotation: field_rotation.unwrap_or(0),
896            display_aspect_ratio: field_display_aspect_ratio.unwrap_or_default(),
897            channels: field_channels.unwrap_or(0),
898            channel_layout: field_channel_layout.unwrap_or_default(),
899            sample_rate_s: field_sample_rate_s.unwrap_or(0),
900            language_iso_639: field_language_iso_639.unwrap_or_default(),
901        };
902        Ok(result)
903    }
904
905    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
906        &self,
907        s: &mut S::SerializeStruct,
908    ) -> Result<(), S::Error> {
909        use serde::ser::SerializeStruct;
910        if self.index != 0 {
911            s.serialize_field("index", &self.index)?;
912        }
913        if !self.codec_type.is_empty() {
914            s.serialize_field("codec_type", &self.codec_type)?;
915        }
916        if !self.codec_name.is_empty() {
917            s.serialize_field("codec_name", &self.codec_name)?;
918        }
919        if self.bitrate_bps != 0 {
920            s.serialize_field("bitrate_bps", &self.bitrate_bps)?;
921        }
922        if self.duration_s != 0.0 {
923            s.serialize_field("duration_s", &self.duration_s)?;
924        }
925        if self.width != 0 {
926            s.serialize_field("width", &self.width)?;
927        }
928        if self.height != 0 {
929            s.serialize_field("height", &self.height)?;
930        }
931        if self.frames_per_second != 0.0 {
932            s.serialize_field("frames_per_second", &self.frames_per_second)?;
933        }
934        if self.rotation != 0 {
935            s.serialize_field("rotation", &self.rotation)?;
936        }
937        if !self.display_aspect_ratio.is_empty() {
938            s.serialize_field("display_aspect_ratio", &self.display_aspect_ratio)?;
939        }
940        if self.channels != 0 {
941            s.serialize_field("channels", &self.channels)?;
942        }
943        if !self.channel_layout.is_empty() {
944            s.serialize_field("channel_layout", &self.channel_layout)?;
945        }
946        if self.sample_rate_s != 0 {
947            s.serialize_field("sample_rate_s", &self.sample_rate_s)?;
948        }
949        if !self.language_iso_639.is_empty() {
950            s.serialize_field("language_iso_639", &self.language_iso_639)?;
951        }
952        Ok(())
953    }
954}
955
956impl<'de> ::serde::de::Deserialize<'de> for ApiMediaStream {
957    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
958        // struct deserializer
959        use serde::de::{MapAccess, Visitor};
960        struct StructVisitor;
961        impl<'de> Visitor<'de> for StructVisitor {
962            type Value = ApiMediaStream;
963            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
964                f.write_str("a ApiMediaStream struct")
965            }
966            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
967                ApiMediaStream::internal_deserialize(map)
968            }
969        }
970        deserializer.deserialize_struct("ApiMediaStream", API_MEDIA_STREAM_FIELDS, StructVisitor)
971    }
972}
973
974impl ::serde::ser::Serialize for ApiMediaStream {
975    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
976        // struct serializer
977        use serde::ser::SerializeStruct;
978        let mut s = serializer.serialize_struct("ApiMediaStream", 14)?;
979        self.internal_serialize::<S>(&mut s)?;
980        s.end()
981    }
982}
983
984/// MS Office document metadata. Mirrors the internal `riviera.OfficeMetadata` message. Some fields
985/// apply only to specific document types (e.g. `slides` for PowerPoint, `words`/`pages` for Word).
986#[derive(Debug, Clone, PartialEq, Eq)]
987#[non_exhaustive] // structs may have more fields added in the future.
988pub struct ApiOfficeMetadata {
989    pub file_type: OfficeFileType,
990    pub creator: String,
991    pub company: String,
992    pub title: String,
993    pub subject: String,
994    pub keywords: String,
995    pub description: String,
996    pub total_edit_time_minutes: u32,
997    /// Word only.
998    pub pages: u32,
999    pub words: u32,
1000    /// PowerPoint only.
1001    pub slides: u32,
1002    pub revision_number: String,
1003}
1004
1005impl Default for ApiOfficeMetadata {
1006    fn default() -> Self {
1007        ApiOfficeMetadata {
1008            file_type: OfficeFileType::OfficeFiletypeUnknown,
1009            creator: String::new(),
1010            company: String::new(),
1011            title: String::new(),
1012            subject: String::new(),
1013            keywords: String::new(),
1014            description: String::new(),
1015            total_edit_time_minutes: 0,
1016            pages: 0,
1017            words: 0,
1018            slides: 0,
1019            revision_number: String::new(),
1020        }
1021    }
1022}
1023
1024impl ApiOfficeMetadata {
1025    pub fn with_file_type(mut self, value: OfficeFileType) -> Self {
1026        self.file_type = value;
1027        self
1028    }
1029
1030    pub fn with_creator(mut self, value: String) -> Self {
1031        self.creator = value;
1032        self
1033    }
1034
1035    pub fn with_company(mut self, value: String) -> Self {
1036        self.company = value;
1037        self
1038    }
1039
1040    pub fn with_title(mut self, value: String) -> Self {
1041        self.title = value;
1042        self
1043    }
1044
1045    pub fn with_subject(mut self, value: String) -> Self {
1046        self.subject = value;
1047        self
1048    }
1049
1050    pub fn with_keywords(mut self, value: String) -> Self {
1051        self.keywords = value;
1052        self
1053    }
1054
1055    pub fn with_description(mut self, value: String) -> Self {
1056        self.description = value;
1057        self
1058    }
1059
1060    pub fn with_total_edit_time_minutes(mut self, value: u32) -> Self {
1061        self.total_edit_time_minutes = value;
1062        self
1063    }
1064
1065    pub fn with_pages(mut self, value: u32) -> Self {
1066        self.pages = value;
1067        self
1068    }
1069
1070    pub fn with_words(mut self, value: u32) -> Self {
1071        self.words = value;
1072        self
1073    }
1074
1075    pub fn with_slides(mut self, value: u32) -> Self {
1076        self.slides = value;
1077        self
1078    }
1079
1080    pub fn with_revision_number(mut self, value: String) -> Self {
1081        self.revision_number = value;
1082        self
1083    }
1084}
1085
1086const API_OFFICE_METADATA_FIELDS: &[&str] = &["file_type",
1087                                              "creator",
1088                                              "company",
1089                                              "title",
1090                                              "subject",
1091                                              "keywords",
1092                                              "description",
1093                                              "total_edit_time_minutes",
1094                                              "pages",
1095                                              "words",
1096                                              "slides",
1097                                              "revision_number"];
1098impl ApiOfficeMetadata {
1099    // no _opt deserializer
1100    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1101        mut map: V,
1102    ) -> Result<ApiOfficeMetadata, V::Error> {
1103        let mut field_file_type = None;
1104        let mut field_creator = None;
1105        let mut field_company = None;
1106        let mut field_title = None;
1107        let mut field_subject = None;
1108        let mut field_keywords = None;
1109        let mut field_description = None;
1110        let mut field_total_edit_time_minutes = None;
1111        let mut field_pages = None;
1112        let mut field_words = None;
1113        let mut field_slides = None;
1114        let mut field_revision_number = None;
1115        while let Some(key) = map.next_key::<&str>()? {
1116            match key {
1117                "file_type" => {
1118                    if field_file_type.is_some() {
1119                        return Err(::serde::de::Error::duplicate_field("file_type"));
1120                    }
1121                    field_file_type = Some(map.next_value()?);
1122                }
1123                "creator" => {
1124                    if field_creator.is_some() {
1125                        return Err(::serde::de::Error::duplicate_field("creator"));
1126                    }
1127                    field_creator = Some(map.next_value()?);
1128                }
1129                "company" => {
1130                    if field_company.is_some() {
1131                        return Err(::serde::de::Error::duplicate_field("company"));
1132                    }
1133                    field_company = Some(map.next_value()?);
1134                }
1135                "title" => {
1136                    if field_title.is_some() {
1137                        return Err(::serde::de::Error::duplicate_field("title"));
1138                    }
1139                    field_title = Some(map.next_value()?);
1140                }
1141                "subject" => {
1142                    if field_subject.is_some() {
1143                        return Err(::serde::de::Error::duplicate_field("subject"));
1144                    }
1145                    field_subject = Some(map.next_value()?);
1146                }
1147                "keywords" => {
1148                    if field_keywords.is_some() {
1149                        return Err(::serde::de::Error::duplicate_field("keywords"));
1150                    }
1151                    field_keywords = Some(map.next_value()?);
1152                }
1153                "description" => {
1154                    if field_description.is_some() {
1155                        return Err(::serde::de::Error::duplicate_field("description"));
1156                    }
1157                    field_description = Some(map.next_value()?);
1158                }
1159                "total_edit_time_minutes" => {
1160                    if field_total_edit_time_minutes.is_some() {
1161                        return Err(::serde::de::Error::duplicate_field("total_edit_time_minutes"));
1162                    }
1163                    field_total_edit_time_minutes = Some(map.next_value()?);
1164                }
1165                "pages" => {
1166                    if field_pages.is_some() {
1167                        return Err(::serde::de::Error::duplicate_field("pages"));
1168                    }
1169                    field_pages = Some(map.next_value()?);
1170                }
1171                "words" => {
1172                    if field_words.is_some() {
1173                        return Err(::serde::de::Error::duplicate_field("words"));
1174                    }
1175                    field_words = Some(map.next_value()?);
1176                }
1177                "slides" => {
1178                    if field_slides.is_some() {
1179                        return Err(::serde::de::Error::duplicate_field("slides"));
1180                    }
1181                    field_slides = Some(map.next_value()?);
1182                }
1183                "revision_number" => {
1184                    if field_revision_number.is_some() {
1185                        return Err(::serde::de::Error::duplicate_field("revision_number"));
1186                    }
1187                    field_revision_number = Some(map.next_value()?);
1188                }
1189                _ => {
1190                    // unknown field allowed and ignored
1191                    map.next_value::<::serde_json::Value>()?;
1192                }
1193            }
1194        }
1195        let result = ApiOfficeMetadata {
1196            file_type: field_file_type.unwrap_or(OfficeFileType::OfficeFiletypeUnknown),
1197            creator: field_creator.unwrap_or_default(),
1198            company: field_company.unwrap_or_default(),
1199            title: field_title.unwrap_or_default(),
1200            subject: field_subject.unwrap_or_default(),
1201            keywords: field_keywords.unwrap_or_default(),
1202            description: field_description.unwrap_or_default(),
1203            total_edit_time_minutes: field_total_edit_time_minutes.unwrap_or(0),
1204            pages: field_pages.unwrap_or(0),
1205            words: field_words.unwrap_or(0),
1206            slides: field_slides.unwrap_or(0),
1207            revision_number: field_revision_number.unwrap_or_default(),
1208        };
1209        Ok(result)
1210    }
1211
1212    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1213        &self,
1214        s: &mut S::SerializeStruct,
1215    ) -> Result<(), S::Error> {
1216        use serde::ser::SerializeStruct;
1217        if self.file_type != OfficeFileType::OfficeFiletypeUnknown {
1218            s.serialize_field("file_type", &self.file_type)?;
1219        }
1220        if !self.creator.is_empty() {
1221            s.serialize_field("creator", &self.creator)?;
1222        }
1223        if !self.company.is_empty() {
1224            s.serialize_field("company", &self.company)?;
1225        }
1226        if !self.title.is_empty() {
1227            s.serialize_field("title", &self.title)?;
1228        }
1229        if !self.subject.is_empty() {
1230            s.serialize_field("subject", &self.subject)?;
1231        }
1232        if !self.keywords.is_empty() {
1233            s.serialize_field("keywords", &self.keywords)?;
1234        }
1235        if !self.description.is_empty() {
1236            s.serialize_field("description", &self.description)?;
1237        }
1238        if self.total_edit_time_minutes != 0 {
1239            s.serialize_field("total_edit_time_minutes", &self.total_edit_time_minutes)?;
1240        }
1241        if self.pages != 0 {
1242            s.serialize_field("pages", &self.pages)?;
1243        }
1244        if self.words != 0 {
1245            s.serialize_field("words", &self.words)?;
1246        }
1247        if self.slides != 0 {
1248            s.serialize_field("slides", &self.slides)?;
1249        }
1250        if !self.revision_number.is_empty() {
1251            s.serialize_field("revision_number", &self.revision_number)?;
1252        }
1253        Ok(())
1254    }
1255}
1256
1257impl<'de> ::serde::de::Deserialize<'de> for ApiOfficeMetadata {
1258    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1259        // struct deserializer
1260        use serde::de::{MapAccess, Visitor};
1261        struct StructVisitor;
1262        impl<'de> Visitor<'de> for StructVisitor {
1263            type Value = ApiOfficeMetadata;
1264            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1265                f.write_str("a ApiOfficeMetadata struct")
1266            }
1267            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1268                ApiOfficeMetadata::internal_deserialize(map)
1269            }
1270        }
1271        deserializer.deserialize_struct("ApiOfficeMetadata", API_OFFICE_METADATA_FIELDS, StructVisitor)
1272    }
1273}
1274
1275impl ::serde::ser::Serialize for ApiOfficeMetadata {
1276    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1277        // struct serializer
1278        use serde::ser::SerializeStruct;
1279        let mut s = serializer.serialize_struct("ApiOfficeMetadata", 12)?;
1280        self.internal_serialize::<S>(&mut s)?;
1281        s.end()
1282    }
1283}
1284
1285/// PDF document metadata.
1286#[derive(Debug, Clone, PartialEq, Eq, Default)]
1287#[non_exhaustive] // structs may have more fields added in the future.
1288pub struct ApiPdfMetadata {
1289    pub pages: u32,
1290    /// Width / height of the first page, in PDF points.
1291    pub width: u32,
1292    pub height: u32,
1293}
1294
1295impl ApiPdfMetadata {
1296    pub fn with_pages(mut self, value: u32) -> Self {
1297        self.pages = value;
1298        self
1299    }
1300
1301    pub fn with_width(mut self, value: u32) -> Self {
1302        self.width = value;
1303        self
1304    }
1305
1306    pub fn with_height(mut self, value: u32) -> Self {
1307        self.height = value;
1308        self
1309    }
1310}
1311
1312const API_PDF_METADATA_FIELDS: &[&str] = &["pages",
1313                                           "width",
1314                                           "height"];
1315impl ApiPdfMetadata {
1316    // no _opt deserializer
1317    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1318        mut map: V,
1319    ) -> Result<ApiPdfMetadata, V::Error> {
1320        let mut field_pages = None;
1321        let mut field_width = None;
1322        let mut field_height = None;
1323        while let Some(key) = map.next_key::<&str>()? {
1324            match key {
1325                "pages" => {
1326                    if field_pages.is_some() {
1327                        return Err(::serde::de::Error::duplicate_field("pages"));
1328                    }
1329                    field_pages = Some(map.next_value()?);
1330                }
1331                "width" => {
1332                    if field_width.is_some() {
1333                        return Err(::serde::de::Error::duplicate_field("width"));
1334                    }
1335                    field_width = Some(map.next_value()?);
1336                }
1337                "height" => {
1338                    if field_height.is_some() {
1339                        return Err(::serde::de::Error::duplicate_field("height"));
1340                    }
1341                    field_height = Some(map.next_value()?);
1342                }
1343                _ => {
1344                    // unknown field allowed and ignored
1345                    map.next_value::<::serde_json::Value>()?;
1346                }
1347            }
1348        }
1349        let result = ApiPdfMetadata {
1350            pages: field_pages.unwrap_or(0),
1351            width: field_width.unwrap_or(0),
1352            height: field_height.unwrap_or(0),
1353        };
1354        Ok(result)
1355    }
1356
1357    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1358        &self,
1359        s: &mut S::SerializeStruct,
1360    ) -> Result<(), S::Error> {
1361        use serde::ser::SerializeStruct;
1362        if self.pages != 0 {
1363            s.serialize_field("pages", &self.pages)?;
1364        }
1365        if self.width != 0 {
1366            s.serialize_field("width", &self.width)?;
1367        }
1368        if self.height != 0 {
1369            s.serialize_field("height", &self.height)?;
1370        }
1371        Ok(())
1372    }
1373}
1374
1375impl<'de> ::serde::de::Deserialize<'de> for ApiPdfMetadata {
1376    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1377        // struct deserializer
1378        use serde::de::{MapAccess, Visitor};
1379        struct StructVisitor;
1380        impl<'de> Visitor<'de> for StructVisitor {
1381            type Value = ApiPdfMetadata;
1382            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1383                f.write_str("a ApiPdfMetadata struct")
1384            }
1385            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1386                ApiPdfMetadata::internal_deserialize(map)
1387            }
1388        }
1389        deserializer.deserialize_struct("ApiPdfMetadata", API_PDF_METADATA_FIELDS, StructVisitor)
1390    }
1391}
1392
1393impl ::serde::ser::Serialize for ApiPdfMetadata {
1394    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1395        // struct serializer
1396        use serde::ser::SerializeStruct;
1397        let mut s = serializer.serialize_struct("ApiPdfMetadata", 3)?;
1398        self.internal_serialize::<S>(&mut s)?;
1399        s.end()
1400    }
1401}
1402
1403/// Structured transcript for APIv2
1404#[derive(Debug, Clone, PartialEq, Default)]
1405#[non_exhaustive] // structs may have more fields added in the future.
1406pub struct ApiStructuredTranscript {
1407    pub segments: Option<Vec<ApiTranscriptSegment>>,
1408    pub transcript_locale: String,
1409}
1410
1411impl ApiStructuredTranscript {
1412    pub fn with_segments(mut self, value: Vec<ApiTranscriptSegment>) -> Self {
1413        self.segments = Some(value);
1414        self
1415    }
1416
1417    pub fn with_transcript_locale(mut self, value: String) -> Self {
1418        self.transcript_locale = value;
1419        self
1420    }
1421}
1422
1423const API_STRUCTURED_TRANSCRIPT_FIELDS: &[&str] = &["segments",
1424                                                    "transcript_locale"];
1425impl ApiStructuredTranscript {
1426    // no _opt deserializer
1427    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1428        mut map: V,
1429    ) -> Result<ApiStructuredTranscript, V::Error> {
1430        let mut field_segments = None;
1431        let mut field_transcript_locale = None;
1432        while let Some(key) = map.next_key::<&str>()? {
1433            match key {
1434                "segments" => {
1435                    if field_segments.is_some() {
1436                        return Err(::serde::de::Error::duplicate_field("segments"));
1437                    }
1438                    field_segments = Some(map.next_value()?);
1439                }
1440                "transcript_locale" => {
1441                    if field_transcript_locale.is_some() {
1442                        return Err(::serde::de::Error::duplicate_field("transcript_locale"));
1443                    }
1444                    field_transcript_locale = Some(map.next_value()?);
1445                }
1446                _ => {
1447                    // unknown field allowed and ignored
1448                    map.next_value::<::serde_json::Value>()?;
1449                }
1450            }
1451        }
1452        let result = ApiStructuredTranscript {
1453            segments: field_segments.and_then(Option::flatten),
1454            transcript_locale: field_transcript_locale.unwrap_or_default(),
1455        };
1456        Ok(result)
1457    }
1458
1459    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1460        &self,
1461        s: &mut S::SerializeStruct,
1462    ) -> Result<(), S::Error> {
1463        use serde::ser::SerializeStruct;
1464        if let Some(val) = &self.segments {
1465            s.serialize_field("segments", val)?;
1466        }
1467        if !self.transcript_locale.is_empty() {
1468            s.serialize_field("transcript_locale", &self.transcript_locale)?;
1469        }
1470        Ok(())
1471    }
1472}
1473
1474impl<'de> ::serde::de::Deserialize<'de> for ApiStructuredTranscript {
1475    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1476        // struct deserializer
1477        use serde::de::{MapAccess, Visitor};
1478        struct StructVisitor;
1479        impl<'de> Visitor<'de> for StructVisitor {
1480            type Value = ApiStructuredTranscript;
1481            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1482                f.write_str("a ApiStructuredTranscript struct")
1483            }
1484            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1485                ApiStructuredTranscript::internal_deserialize(map)
1486            }
1487        }
1488        deserializer.deserialize_struct("ApiStructuredTranscript", API_STRUCTURED_TRANSCRIPT_FIELDS, StructVisitor)
1489    }
1490}
1491
1492impl ::serde::ser::Serialize for ApiStructuredTranscript {
1493    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1494        // struct serializer
1495        use serde::ser::SerializeStruct;
1496        let mut s = serializer.serialize_struct("ApiStructuredTranscript", 2)?;
1497        self.internal_serialize::<S>(&mut s)?;
1498        s.end()
1499    }
1500}
1501
1502/// Transcript segment for APIv2
1503#[derive(Debug, Clone, PartialEq, Default)]
1504#[non_exhaustive] // structs may have more fields added in the future.
1505pub struct ApiTranscriptSegment {
1506    pub text: String,
1507    pub start_time: f64,
1508    pub end_time: f64,
1509}
1510
1511impl ApiTranscriptSegment {
1512    pub fn with_text(mut self, value: String) -> Self {
1513        self.text = value;
1514        self
1515    }
1516
1517    pub fn with_start_time(mut self, value: f64) -> Self {
1518        self.start_time = value;
1519        self
1520    }
1521
1522    pub fn with_end_time(mut self, value: f64) -> Self {
1523        self.end_time = value;
1524        self
1525    }
1526}
1527
1528const API_TRANSCRIPT_SEGMENT_FIELDS: &[&str] = &["text",
1529                                                 "start_time",
1530                                                 "end_time"];
1531impl ApiTranscriptSegment {
1532    // no _opt deserializer
1533    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1534        mut map: V,
1535    ) -> Result<ApiTranscriptSegment, V::Error> {
1536        let mut field_text = None;
1537        let mut field_start_time = None;
1538        let mut field_end_time = None;
1539        while let Some(key) = map.next_key::<&str>()? {
1540            match key {
1541                "text" => {
1542                    if field_text.is_some() {
1543                        return Err(::serde::de::Error::duplicate_field("text"));
1544                    }
1545                    field_text = Some(map.next_value()?);
1546                }
1547                "start_time" => {
1548                    if field_start_time.is_some() {
1549                        return Err(::serde::de::Error::duplicate_field("start_time"));
1550                    }
1551                    field_start_time = Some(map.next_value()?);
1552                }
1553                "end_time" => {
1554                    if field_end_time.is_some() {
1555                        return Err(::serde::de::Error::duplicate_field("end_time"));
1556                    }
1557                    field_end_time = Some(map.next_value()?);
1558                }
1559                _ => {
1560                    // unknown field allowed and ignored
1561                    map.next_value::<::serde_json::Value>()?;
1562                }
1563            }
1564        }
1565        let result = ApiTranscriptSegment {
1566            text: field_text.unwrap_or_default(),
1567            start_time: field_start_time.unwrap_or(0.0),
1568            end_time: field_end_time.unwrap_or(0.0),
1569        };
1570        Ok(result)
1571    }
1572
1573    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1574        &self,
1575        s: &mut S::SerializeStruct,
1576    ) -> Result<(), S::Error> {
1577        use serde::ser::SerializeStruct;
1578        if !self.text.is_empty() {
1579            s.serialize_field("text", &self.text)?;
1580        }
1581        if self.start_time != 0.0 {
1582            s.serialize_field("start_time", &self.start_time)?;
1583        }
1584        if self.end_time != 0.0 {
1585            s.serialize_field("end_time", &self.end_time)?;
1586        }
1587        Ok(())
1588    }
1589}
1590
1591impl<'de> ::serde::de::Deserialize<'de> for ApiTranscriptSegment {
1592    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1593        // struct deserializer
1594        use serde::de::{MapAccess, Visitor};
1595        struct StructVisitor;
1596        impl<'de> Visitor<'de> for StructVisitor {
1597            type Value = ApiTranscriptSegment;
1598            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1599                f.write_str("a ApiTranscriptSegment struct")
1600            }
1601            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1602                ApiTranscriptSegment::internal_deserialize(map)
1603            }
1604        }
1605        deserializer.deserialize_struct("ApiTranscriptSegment", API_TRANSCRIPT_SEGMENT_FIELDS, StructVisitor)
1606    }
1607}
1608
1609impl ::serde::ser::Serialize for ApiTranscriptSegment {
1610    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1611        // struct serializer
1612        use serde::ser::SerializeStruct;
1613        let mut s = serializer.serialize_struct("ApiTranscriptSegment", 3)?;
1614        self.internal_serialize::<S>(&mut s)?;
1615        s.end()
1616    }
1617}
1618
1619#[derive(Debug, Clone, PartialEq, Eq)]
1620#[non_exhaustive] // variants may be added in the future
1621pub enum ContentApiV2Error {
1622    ServerError(String),
1623    UserError(String),
1624    MediaDurationError(MediaDurationError),
1625    NoAudioError,
1626    LinkDownloadDisabledError,
1627    SharedLinkPasswordProtected,
1628    LimitExceededError,
1629    /// The referenced file does not exist or is not accessible.
1630    NotFoundError,
1631    /// The target is a folder, not a file.
1632    IsAFolderError,
1633    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1634    /// typically indicates that this SDK version is out of date.
1635    Other,
1636}
1637
1638impl<'de> ::serde::de::Deserialize<'de> for ContentApiV2Error {
1639    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1640        // union deserializer
1641        use serde::de::{self, MapAccess, Visitor};
1642        struct EnumVisitor;
1643        impl<'de> Visitor<'de> for EnumVisitor {
1644            type Value = ContentApiV2Error;
1645            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1646                f.write_str("a ContentApiV2Error structure")
1647            }
1648            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1649                let tag: &str = match map.next_key()? {
1650                    Some(".tag") => map.next_value()?,
1651                    _ => return Err(de::Error::missing_field(".tag"))
1652                };
1653                let value = match tag {
1654                    "server_error" => {
1655                        match map.next_key()? {
1656                            Some("server_error") => ContentApiV2Error::ServerError(map.next_value()?),
1657                            None => return Err(de::Error::missing_field("server_error")),
1658                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1659                        }
1660                    }
1661                    "user_error" => {
1662                        match map.next_key()? {
1663                            Some("user_error") => ContentApiV2Error::UserError(map.next_value()?),
1664                            None => return Err(de::Error::missing_field("user_error")),
1665                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1666                        }
1667                    }
1668                    "media_duration_error" => ContentApiV2Error::MediaDurationError(MediaDurationError::internal_deserialize(&mut map)?),
1669                    "no_audio_error" => ContentApiV2Error::NoAudioError,
1670                    "link_download_disabled_error" => ContentApiV2Error::LinkDownloadDisabledError,
1671                    "shared_link_password_protected" => ContentApiV2Error::SharedLinkPasswordProtected,
1672                    "limit_exceeded_error" => ContentApiV2Error::LimitExceededError,
1673                    "not_found_error" => ContentApiV2Error::NotFoundError,
1674                    "is_a_folder_error" => ContentApiV2Error::IsAFolderError,
1675                    _ => ContentApiV2Error::Other,
1676                };
1677                crate::eat_json_fields(&mut map)?;
1678                Ok(value)
1679            }
1680        }
1681        const VARIANTS: &[&str] = &["server_error",
1682                                    "user_error",
1683                                    "media_duration_error",
1684                                    "no_audio_error",
1685                                    "link_download_disabled_error",
1686                                    "shared_link_password_protected",
1687                                    "limit_exceeded_error",
1688                                    "not_found_error",
1689                                    "is_a_folder_error",
1690                                    "other"];
1691        deserializer.deserialize_struct("ContentApiV2Error", VARIANTS, EnumVisitor)
1692    }
1693}
1694
1695impl ::serde::ser::Serialize for ContentApiV2Error {
1696    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1697        // union serializer
1698        use serde::ser::SerializeStruct;
1699        match self {
1700            ContentApiV2Error::ServerError(x) => {
1701                // primitive
1702                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
1703                s.serialize_field(".tag", "server_error")?;
1704                s.serialize_field("server_error", x)?;
1705                s.end()
1706            }
1707            ContentApiV2Error::UserError(x) => {
1708                // primitive
1709                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
1710                s.serialize_field(".tag", "user_error")?;
1711                s.serialize_field("user_error", x)?;
1712                s.end()
1713            }
1714            ContentApiV2Error::MediaDurationError(x) => {
1715                // struct
1716                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
1717                s.serialize_field(".tag", "media_duration_error")?;
1718                x.internal_serialize::<S>(&mut s)?;
1719                s.end()
1720            }
1721            ContentApiV2Error::NoAudioError => {
1722                // unit
1723                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1724                s.serialize_field(".tag", "no_audio_error")?;
1725                s.end()
1726            }
1727            ContentApiV2Error::LinkDownloadDisabledError => {
1728                // unit
1729                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1730                s.serialize_field(".tag", "link_download_disabled_error")?;
1731                s.end()
1732            }
1733            ContentApiV2Error::SharedLinkPasswordProtected => {
1734                // unit
1735                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1736                s.serialize_field(".tag", "shared_link_password_protected")?;
1737                s.end()
1738            }
1739            ContentApiV2Error::LimitExceededError => {
1740                // unit
1741                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1742                s.serialize_field(".tag", "limit_exceeded_error")?;
1743                s.end()
1744            }
1745            ContentApiV2Error::NotFoundError => {
1746                // unit
1747                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1748                s.serialize_field(".tag", "not_found_error")?;
1749                s.end()
1750            }
1751            ContentApiV2Error::IsAFolderError => {
1752                // unit
1753                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1754                s.serialize_field(".tag", "is_a_folder_error")?;
1755                s.end()
1756            }
1757            ContentApiV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1758        }
1759    }
1760}
1761
1762impl ::std::error::Error for ContentApiV2Error {
1763}
1764
1765impl ::std::fmt::Display for ContentApiV2Error {
1766    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1767        match self {
1768            ContentApiV2Error::ServerError(inner) => write!(f, "server_error: {:?}", inner),
1769            ContentApiV2Error::UserError(inner) => write!(f, "user_error: {:?}", inner),
1770            ContentApiV2Error::MediaDurationError(inner) => write!(f, "media_duration_error: {:?}", inner),
1771            ContentApiV2Error::NotFoundError => f.write_str("The referenced file does not exist or is not accessible."),
1772            ContentApiV2Error::IsAFolderError => f.write_str("The target is a folder, not a file."),
1773            _ => write!(f, "{:?}", *self),
1774        }
1775    }
1776}
1777
1778#[derive(Debug, Clone, PartialEq, Eq)]
1779#[non_exhaustive] // variants may be added in the future
1780pub enum ErrorCode {
1781    UnknownError,
1782    /// 400
1783    BadRequest,
1784    /// 409
1785    ApiError,
1786    /// 403
1787    AccessError,
1788    /// 429
1789    RatelimitError,
1790    /// 503
1791    Unavailable,
1792    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1793    /// typically indicates that this SDK version is out of date.
1794    Other,
1795}
1796
1797impl<'de> ::serde::de::Deserialize<'de> for ErrorCode {
1798    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1799        // union deserializer
1800        use serde::de::{self, MapAccess, Visitor};
1801        struct EnumVisitor;
1802        impl<'de> Visitor<'de> for EnumVisitor {
1803            type Value = ErrorCode;
1804            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1805                f.write_str("a ErrorCode structure")
1806            }
1807            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1808                let tag: &str = match map.next_key()? {
1809                    Some(".tag") => map.next_value()?,
1810                    _ => return Err(de::Error::missing_field(".tag"))
1811                };
1812                let value = match tag {
1813                    "unknown_error" => ErrorCode::UnknownError,
1814                    "bad_request" => ErrorCode::BadRequest,
1815                    "api_error" => ErrorCode::ApiError,
1816                    "access_error" => ErrorCode::AccessError,
1817                    "ratelimit_error" => ErrorCode::RatelimitError,
1818                    "unavailable" => ErrorCode::Unavailable,
1819                    _ => ErrorCode::Other,
1820                };
1821                crate::eat_json_fields(&mut map)?;
1822                Ok(value)
1823            }
1824        }
1825        const VARIANTS: &[&str] = &["unknown_error",
1826                                    "bad_request",
1827                                    "api_error",
1828                                    "access_error",
1829                                    "ratelimit_error",
1830                                    "unavailable",
1831                                    "other"];
1832        deserializer.deserialize_struct("ErrorCode", VARIANTS, EnumVisitor)
1833    }
1834}
1835
1836impl ::serde::ser::Serialize for ErrorCode {
1837    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1838        // union serializer
1839        use serde::ser::SerializeStruct;
1840        match self {
1841            ErrorCode::UnknownError => {
1842                // unit
1843                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
1844                s.serialize_field(".tag", "unknown_error")?;
1845                s.end()
1846            }
1847            ErrorCode::BadRequest => {
1848                // unit
1849                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
1850                s.serialize_field(".tag", "bad_request")?;
1851                s.end()
1852            }
1853            ErrorCode::ApiError => {
1854                // unit
1855                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
1856                s.serialize_field(".tag", "api_error")?;
1857                s.end()
1858            }
1859            ErrorCode::AccessError => {
1860                // unit
1861                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
1862                s.serialize_field(".tag", "access_error")?;
1863                s.end()
1864            }
1865            ErrorCode::RatelimitError => {
1866                // unit
1867                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
1868                s.serialize_field(".tag", "ratelimit_error")?;
1869                s.end()
1870            }
1871            ErrorCode::Unavailable => {
1872                // unit
1873                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
1874                s.serialize_field(".tag", "unavailable")?;
1875                s.end()
1876            }
1877            ErrorCode::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1878        }
1879    }
1880}
1881
1882#[derive(Debug, Clone, PartialEq, Eq)]
1883#[non_exhaustive] // variants may be added in the future
1884pub enum FileIdOrUrl {
1885    FileId(String),
1886    Url(String),
1887    Path(String),
1888    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1889    /// typically indicates that this SDK version is out of date.
1890    Other,
1891}
1892
1893impl<'de> ::serde::de::Deserialize<'de> for FileIdOrUrl {
1894    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1895        // union deserializer
1896        use serde::de::{self, MapAccess, Visitor};
1897        struct EnumVisitor;
1898        impl<'de> Visitor<'de> for EnumVisitor {
1899            type Value = FileIdOrUrl;
1900            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1901                f.write_str("a FileIdOrUrl structure")
1902            }
1903            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1904                let tag: &str = match map.next_key()? {
1905                    Some(".tag") => map.next_value()?,
1906                    _ => return Err(de::Error::missing_field(".tag"))
1907                };
1908                let value = match tag {
1909                    "file_id" => {
1910                        match map.next_key()? {
1911                            Some("file_id") => FileIdOrUrl::FileId(map.next_value()?),
1912                            None => return Err(de::Error::missing_field("file_id")),
1913                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1914                        }
1915                    }
1916                    "url" => {
1917                        match map.next_key()? {
1918                            Some("url") => FileIdOrUrl::Url(map.next_value()?),
1919                            None => return Err(de::Error::missing_field("url")),
1920                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1921                        }
1922                    }
1923                    "path" => {
1924                        match map.next_key()? {
1925                            Some("path") => FileIdOrUrl::Path(map.next_value()?),
1926                            None => return Err(de::Error::missing_field("path")),
1927                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1928                        }
1929                    }
1930                    _ => FileIdOrUrl::Other,
1931                };
1932                crate::eat_json_fields(&mut map)?;
1933                Ok(value)
1934            }
1935        }
1936        const VARIANTS: &[&str] = &["file_id",
1937                                    "url",
1938                                    "path",
1939                                    "other"];
1940        deserializer.deserialize_struct("FileIdOrUrl", VARIANTS, EnumVisitor)
1941    }
1942}
1943
1944impl ::serde::ser::Serialize for FileIdOrUrl {
1945    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1946        // union serializer
1947        use serde::ser::SerializeStruct;
1948        match self {
1949            FileIdOrUrl::FileId(x) => {
1950                // primitive
1951                let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
1952                s.serialize_field(".tag", "file_id")?;
1953                s.serialize_field("file_id", x)?;
1954                s.end()
1955            }
1956            FileIdOrUrl::Url(x) => {
1957                // primitive
1958                let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
1959                s.serialize_field(".tag", "url")?;
1960                s.serialize_field("url", x)?;
1961                s.end()
1962            }
1963            FileIdOrUrl::Path(x) => {
1964                // primitive
1965                let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
1966                s.serialize_field(".tag", "path")?;
1967                s.serialize_field("path", x)?;
1968                s.end()
1969            }
1970            FileIdOrUrl::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1971        }
1972    }
1973}
1974
1975/// Arguments for the asynchronous `get_markdown_async` route. Exactly one of `file_id`, `path`, or
1976/// `url` must be supplied via `file_id_or_url` to identify the document to convert to markdown.
1977#[derive(Debug, Clone, PartialEq, Eq, Default)]
1978#[non_exhaustive] // structs may have more fields added in the future.
1979pub struct GetMarkdownArgs {
1980    /// Identifier of the document to convert. Callers must set exactly one of the oneof variants: -
1981    /// file_id: a Dropbox-issued file id (format: "id:<id>") for a file the authenticated user has
1982    /// access to. - path: an absolute Dropbox path, e.g. "/folder/report.docx". - url: either a
1983    /// Dropbox shared link (www.dropbox.com) or an external HTTPS URL pointing to a supported
1984    /// document file. - Dropbox shared links are resolved internally using the caller's
1985    /// authenticated identity and the link's visibility / download settings. They therefore require
1986    /// an authenticated user context (anonymous `url` requests against Dropbox links are rejected
1987    /// with an `ACCESS_ERROR`). Links protected by a password are rejected with
1988    /// `shared_link_password_protected`; links with downloads disabled are rejected with
1989    /// `link_download_disabled_error`. - External URLs are fetched over HTTPS through the backend's
1990    /// egress proxy and must point at a supported document file extension. The referenced file must
1991    /// be a document in a supported format; requests against unsupported formats return
1992    /// `unsupported_format_error`.
1993    pub file_id_or_url: Option<FileIdOrUrl>,
1994    /// Enable OCR for PDF documents. Processing is slower when enabled.
1995    pub enable_ocr: bool,
1996    /// When true, embed images as base64 data URIs in the markdown output. This can significantly
1997    /// increase output size.
1998    pub embed_images: bool,
1999}
2000
2001impl GetMarkdownArgs {
2002    pub fn with_file_id_or_url(mut self, value: FileIdOrUrl) -> Self {
2003        self.file_id_or_url = Some(value);
2004        self
2005    }
2006
2007    pub fn with_enable_ocr(mut self, value: bool) -> Self {
2008        self.enable_ocr = value;
2009        self
2010    }
2011
2012    pub fn with_embed_images(mut self, value: bool) -> Self {
2013        self.embed_images = value;
2014        self
2015    }
2016}
2017
2018const GET_MARKDOWN_ARGS_FIELDS: &[&str] = &["file_id_or_url",
2019                                            "enable_ocr",
2020                                            "embed_images"];
2021impl GetMarkdownArgs {
2022    // no _opt deserializer
2023    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2024        mut map: V,
2025    ) -> Result<GetMarkdownArgs, V::Error> {
2026        let mut field_file_id_or_url = None;
2027        let mut field_enable_ocr = None;
2028        let mut field_embed_images = None;
2029        while let Some(key) = map.next_key::<&str>()? {
2030            match key {
2031                "file_id_or_url" => {
2032                    if field_file_id_or_url.is_some() {
2033                        return Err(::serde::de::Error::duplicate_field("file_id_or_url"));
2034                    }
2035                    field_file_id_or_url = Some(map.next_value()?);
2036                }
2037                "enable_ocr" => {
2038                    if field_enable_ocr.is_some() {
2039                        return Err(::serde::de::Error::duplicate_field("enable_ocr"));
2040                    }
2041                    field_enable_ocr = Some(map.next_value()?);
2042                }
2043                "embed_images" => {
2044                    if field_embed_images.is_some() {
2045                        return Err(::serde::de::Error::duplicate_field("embed_images"));
2046                    }
2047                    field_embed_images = Some(map.next_value()?);
2048                }
2049                _ => {
2050                    // unknown field allowed and ignored
2051                    map.next_value::<::serde_json::Value>()?;
2052                }
2053            }
2054        }
2055        let result = GetMarkdownArgs {
2056            file_id_or_url: field_file_id_or_url.and_then(Option::flatten),
2057            enable_ocr: field_enable_ocr.unwrap_or(false),
2058            embed_images: field_embed_images.unwrap_or(false),
2059        };
2060        Ok(result)
2061    }
2062
2063    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2064        &self,
2065        s: &mut S::SerializeStruct,
2066    ) -> Result<(), S::Error> {
2067        use serde::ser::SerializeStruct;
2068        if let Some(val) = &self.file_id_or_url {
2069            s.serialize_field("file_id_or_url", val)?;
2070        }
2071        if self.enable_ocr {
2072            s.serialize_field("enable_ocr", &self.enable_ocr)?;
2073        }
2074        if self.embed_images {
2075            s.serialize_field("embed_images", &self.embed_images)?;
2076        }
2077        Ok(())
2078    }
2079}
2080
2081impl<'de> ::serde::de::Deserialize<'de> for GetMarkdownArgs {
2082    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2083        // struct deserializer
2084        use serde::de::{MapAccess, Visitor};
2085        struct StructVisitor;
2086        impl<'de> Visitor<'de> for StructVisitor {
2087            type Value = GetMarkdownArgs;
2088            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2089                f.write_str("a GetMarkdownArgs struct")
2090            }
2091            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2092                GetMarkdownArgs::internal_deserialize(map)
2093            }
2094        }
2095        deserializer.deserialize_struct("GetMarkdownArgs", GET_MARKDOWN_ARGS_FIELDS, StructVisitor)
2096    }
2097}
2098
2099impl ::serde::ser::Serialize for GetMarkdownArgs {
2100    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2101        // struct serializer
2102        use serde::ser::SerializeStruct;
2103        let mut s = serializer.serialize_struct("GetMarkdownArgs", 3)?;
2104        self.internal_serialize::<S>(&mut s)?;
2105        s.end()
2106    }
2107}
2108
2109/// Result type for EventBus async check
2110#[derive(Debug, Clone, PartialEq, Eq)]
2111#[non_exhaustive] // variants may be added in the future
2112pub enum GetMarkdownAsyncCheckResult {
2113    InProgress,
2114    Complete(GetMarkdownResult),
2115    Failed(GetMarkdownAsyncError),
2116    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2117    /// typically indicates that this SDK version is out of date.
2118    Other,
2119}
2120
2121impl<'de> ::serde::de::Deserialize<'de> for GetMarkdownAsyncCheckResult {
2122    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2123        // union deserializer
2124        use serde::de::{self, MapAccess, Visitor};
2125        struct EnumVisitor;
2126        impl<'de> Visitor<'de> for EnumVisitor {
2127            type Value = GetMarkdownAsyncCheckResult;
2128            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2129                f.write_str("a GetMarkdownAsyncCheckResult structure")
2130            }
2131            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2132                let tag: &str = match map.next_key()? {
2133                    Some(".tag") => map.next_value()?,
2134                    _ => return Err(de::Error::missing_field(".tag"))
2135                };
2136                let value = match tag {
2137                    "in_progress" => GetMarkdownAsyncCheckResult::InProgress,
2138                    "complete" => GetMarkdownAsyncCheckResult::Complete(GetMarkdownResult::internal_deserialize(&mut map)?),
2139                    "failed" => GetMarkdownAsyncCheckResult::Failed(GetMarkdownAsyncError::internal_deserialize(&mut map)?),
2140                    _ => GetMarkdownAsyncCheckResult::Other,
2141                };
2142                crate::eat_json_fields(&mut map)?;
2143                Ok(value)
2144            }
2145        }
2146        const VARIANTS: &[&str] = &["in_progress",
2147                                    "complete",
2148                                    "failed",
2149                                    "other"];
2150        deserializer.deserialize_struct("GetMarkdownAsyncCheckResult", VARIANTS, EnumVisitor)
2151    }
2152}
2153
2154impl ::serde::ser::Serialize for GetMarkdownAsyncCheckResult {
2155    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2156        // union serializer
2157        use serde::ser::SerializeStruct;
2158        match self {
2159            GetMarkdownAsyncCheckResult::InProgress => {
2160                // unit
2161                let mut s = serializer.serialize_struct("GetMarkdownAsyncCheckResult", 1)?;
2162                s.serialize_field(".tag", "in_progress")?;
2163                s.end()
2164            }
2165            GetMarkdownAsyncCheckResult::Complete(x) => {
2166                // struct
2167                let mut s = serializer.serialize_struct("GetMarkdownAsyncCheckResult", 2)?;
2168                s.serialize_field(".tag", "complete")?;
2169                x.internal_serialize::<S>(&mut s)?;
2170                s.end()
2171            }
2172            GetMarkdownAsyncCheckResult::Failed(x) => {
2173                // struct
2174                let mut s = serializer.serialize_struct("GetMarkdownAsyncCheckResult", 3)?;
2175                s.serialize_field(".tag", "failed")?;
2176                x.internal_serialize::<S>(&mut s)?;
2177                s.end()
2178            }
2179            GetMarkdownAsyncCheckResult::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2180        }
2181    }
2182}
2183
2184#[derive(Debug, Clone, PartialEq, Eq)]
2185#[non_exhaustive] // structs may have more fields added in the future.
2186pub struct GetMarkdownAsyncError {
2187    pub error_code: ErrorCode,
2188    pub error_details: Option<MarkdownConversionApiV2Error>,
2189}
2190
2191impl Default for GetMarkdownAsyncError {
2192    fn default() -> Self {
2193        GetMarkdownAsyncError {
2194            error_code: ErrorCode::UnknownError,
2195            error_details: None,
2196        }
2197    }
2198}
2199
2200impl GetMarkdownAsyncError {
2201    pub fn with_error_code(mut self, value: ErrorCode) -> Self {
2202        self.error_code = value;
2203        self
2204    }
2205
2206    pub fn with_error_details(mut self, value: MarkdownConversionApiV2Error) -> Self {
2207        self.error_details = Some(value);
2208        self
2209    }
2210}
2211
2212const GET_MARKDOWN_ASYNC_ERROR_FIELDS: &[&str] = &["error_code",
2213                                                   "error_details"];
2214impl GetMarkdownAsyncError {
2215    // no _opt deserializer
2216    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2217        mut map: V,
2218    ) -> Result<GetMarkdownAsyncError, V::Error> {
2219        let mut field_error_code = None;
2220        let mut field_error_details = None;
2221        while let Some(key) = map.next_key::<&str>()? {
2222            match key {
2223                "error_code" => {
2224                    if field_error_code.is_some() {
2225                        return Err(::serde::de::Error::duplicate_field("error_code"));
2226                    }
2227                    field_error_code = Some(map.next_value()?);
2228                }
2229                "error_details" => {
2230                    if field_error_details.is_some() {
2231                        return Err(::serde::de::Error::duplicate_field("error_details"));
2232                    }
2233                    field_error_details = Some(map.next_value()?);
2234                }
2235                _ => {
2236                    // unknown field allowed and ignored
2237                    map.next_value::<::serde_json::Value>()?;
2238                }
2239            }
2240        }
2241        let result = GetMarkdownAsyncError {
2242            error_code: field_error_code.unwrap_or(ErrorCode::UnknownError),
2243            error_details: field_error_details.and_then(Option::flatten),
2244        };
2245        Ok(result)
2246    }
2247
2248    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2249        &self,
2250        s: &mut S::SerializeStruct,
2251    ) -> Result<(), S::Error> {
2252        use serde::ser::SerializeStruct;
2253        if self.error_code != ErrorCode::UnknownError {
2254            s.serialize_field("error_code", &self.error_code)?;
2255        }
2256        if let Some(val) = &self.error_details {
2257            s.serialize_field("error_details", val)?;
2258        }
2259        Ok(())
2260    }
2261}
2262
2263impl<'de> ::serde::de::Deserialize<'de> for GetMarkdownAsyncError {
2264    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2265        // struct deserializer
2266        use serde::de::{MapAccess, Visitor};
2267        struct StructVisitor;
2268        impl<'de> Visitor<'de> for StructVisitor {
2269            type Value = GetMarkdownAsyncError;
2270            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2271                f.write_str("a GetMarkdownAsyncError struct")
2272            }
2273            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2274                GetMarkdownAsyncError::internal_deserialize(map)
2275            }
2276        }
2277        deserializer.deserialize_struct("GetMarkdownAsyncError", GET_MARKDOWN_ASYNC_ERROR_FIELDS, StructVisitor)
2278    }
2279}
2280
2281impl ::serde::ser::Serialize for GetMarkdownAsyncError {
2282    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2283        // struct serializer
2284        use serde::ser::SerializeStruct;
2285        let mut s = serializer.serialize_struct("GetMarkdownAsyncError", 2)?;
2286        self.internal_serialize::<S>(&mut s)?;
2287        s.end()
2288    }
2289}
2290
2291#[derive(Debug, Clone, PartialEq, Eq, Default)]
2292#[non_exhaustive] // structs may have more fields added in the future.
2293pub struct GetMarkdownResult {
2294    /// The converted markdown content
2295    pub markdown: String,
2296}
2297
2298impl GetMarkdownResult {
2299    pub fn with_markdown(mut self, value: String) -> Self {
2300        self.markdown = value;
2301        self
2302    }
2303}
2304
2305const GET_MARKDOWN_RESULT_FIELDS: &[&str] = &["markdown"];
2306impl GetMarkdownResult {
2307    // no _opt deserializer
2308    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2309        mut map: V,
2310    ) -> Result<GetMarkdownResult, V::Error> {
2311        let mut field_markdown = None;
2312        while let Some(key) = map.next_key::<&str>()? {
2313            match key {
2314                "markdown" => {
2315                    if field_markdown.is_some() {
2316                        return Err(::serde::de::Error::duplicate_field("markdown"));
2317                    }
2318                    field_markdown = Some(map.next_value()?);
2319                }
2320                _ => {
2321                    // unknown field allowed and ignored
2322                    map.next_value::<::serde_json::Value>()?;
2323                }
2324            }
2325        }
2326        let result = GetMarkdownResult {
2327            markdown: field_markdown.unwrap_or_default(),
2328        };
2329        Ok(result)
2330    }
2331
2332    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2333        &self,
2334        s: &mut S::SerializeStruct,
2335    ) -> Result<(), S::Error> {
2336        use serde::ser::SerializeStruct;
2337        if !self.markdown.is_empty() {
2338            s.serialize_field("markdown", &self.markdown)?;
2339        }
2340        Ok(())
2341    }
2342}
2343
2344impl<'de> ::serde::de::Deserialize<'de> for GetMarkdownResult {
2345    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2346        // struct deserializer
2347        use serde::de::{MapAccess, Visitor};
2348        struct StructVisitor;
2349        impl<'de> Visitor<'de> for StructVisitor {
2350            type Value = GetMarkdownResult;
2351            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2352                f.write_str("a GetMarkdownResult struct")
2353            }
2354            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2355                GetMarkdownResult::internal_deserialize(map)
2356            }
2357        }
2358        deserializer.deserialize_struct("GetMarkdownResult", GET_MARKDOWN_RESULT_FIELDS, StructVisitor)
2359    }
2360}
2361
2362impl ::serde::ser::Serialize for GetMarkdownResult {
2363    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2364        // struct serializer
2365        use serde::ser::SerializeStruct;
2366        let mut s = serializer.serialize_struct("GetMarkdownResult", 1)?;
2367        self.internal_serialize::<S>(&mut s)?;
2368        s.end()
2369    }
2370}
2371
2372/// Arguments for the asynchronous `get_metadata_async` route. Exactly one of `file_id`, `path`, or
2373/// `url` must be supplied via `file_id_or_url` to identify the file whose metadata should be
2374/// extracted.
2375#[derive(Debug, Clone, PartialEq, Eq, Default)]
2376#[non_exhaustive] // structs may have more fields added in the future.
2377pub struct GetMetadataArgs {
2378    /// Identifier of the file to extract metadata from. Callers must set exactly one of the oneof
2379    /// variants: - file_id: a Dropbox-issued file id (format: "id:<id>") for a file the
2380    /// authenticated user has access to. - path: an absolute Dropbox path, e.g.
2381    /// "/folder/photo.jpg". - url: either a Dropbox shared link (www.dropbox.com) or an external
2382    /// HTTPS URL pointing to a supported file. - Dropbox shared links are resolved internally using
2383    /// the caller's authenticated identity and the link's visibility / download settings. They
2384    /// therefore require an authenticated user context (anonymous `url` requests against Dropbox
2385    /// links are rejected with an `ACCESS_ERROR`). Links protected by a password are rejected with
2386    /// `shared_link_password_protected`; links with downloads disabled are rejected with
2387    /// `link_download_disabled_error`. - External URLs are fetched over HTTPS through the backend's
2388    /// egress proxy and must point at a supported file extension. The kind of metadata returned is
2389    /// determined by the file type: image files return EXIF metadata, audio/video files return
2390    /// media metadata, PDFs return PDF metadata, and MS Office documents (docx, pptx, xlsx) return
2391    /// Office metadata. Requests against unsupported formats return `unsupported_format_error`.
2392    pub file_id_or_url: Option<FileIdOrUrl>,
2393}
2394
2395impl GetMetadataArgs {
2396    pub fn with_file_id_or_url(mut self, value: FileIdOrUrl) -> Self {
2397        self.file_id_or_url = Some(value);
2398        self
2399    }
2400}
2401
2402const GET_METADATA_ARGS_FIELDS: &[&str] = &["file_id_or_url"];
2403impl GetMetadataArgs {
2404    // no _opt deserializer
2405    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2406        mut map: V,
2407    ) -> Result<GetMetadataArgs, V::Error> {
2408        let mut field_file_id_or_url = None;
2409        while let Some(key) = map.next_key::<&str>()? {
2410            match key {
2411                "file_id_or_url" => {
2412                    if field_file_id_or_url.is_some() {
2413                        return Err(::serde::de::Error::duplicate_field("file_id_or_url"));
2414                    }
2415                    field_file_id_or_url = Some(map.next_value()?);
2416                }
2417                _ => {
2418                    // unknown field allowed and ignored
2419                    map.next_value::<::serde_json::Value>()?;
2420                }
2421            }
2422        }
2423        let result = GetMetadataArgs {
2424            file_id_or_url: field_file_id_or_url.and_then(Option::flatten),
2425        };
2426        Ok(result)
2427    }
2428
2429    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2430        &self,
2431        s: &mut S::SerializeStruct,
2432    ) -> Result<(), S::Error> {
2433        use serde::ser::SerializeStruct;
2434        if let Some(val) = &self.file_id_or_url {
2435            s.serialize_field("file_id_or_url", val)?;
2436        }
2437        Ok(())
2438    }
2439}
2440
2441impl<'de> ::serde::de::Deserialize<'de> for GetMetadataArgs {
2442    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2443        // struct deserializer
2444        use serde::de::{MapAccess, Visitor};
2445        struct StructVisitor;
2446        impl<'de> Visitor<'de> for StructVisitor {
2447            type Value = GetMetadataArgs;
2448            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2449                f.write_str("a GetMetadataArgs struct")
2450            }
2451            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2452                GetMetadataArgs::internal_deserialize(map)
2453            }
2454        }
2455        deserializer.deserialize_struct("GetMetadataArgs", GET_METADATA_ARGS_FIELDS, StructVisitor)
2456    }
2457}
2458
2459impl ::serde::ser::Serialize for GetMetadataArgs {
2460    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2461        // struct serializer
2462        use serde::ser::SerializeStruct;
2463        let mut s = serializer.serialize_struct("GetMetadataArgs", 1)?;
2464        self.internal_serialize::<S>(&mut s)?;
2465        s.end()
2466    }
2467}
2468
2469/// Result type for EventBus async check - must end in "CheckResult"
2470#[derive(Debug, Clone, PartialEq)]
2471#[non_exhaustive] // variants may be added in the future
2472pub enum GetMetadataAsyncCheckResult {
2473    InProgress,
2474    Complete(GetMetadataResult),
2475    Failed(GetMetadataAsyncError),
2476    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2477    /// typically indicates that this SDK version is out of date.
2478    Other,
2479}
2480
2481impl<'de> ::serde::de::Deserialize<'de> for GetMetadataAsyncCheckResult {
2482    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2483        // union deserializer
2484        use serde::de::{self, MapAccess, Visitor};
2485        struct EnumVisitor;
2486        impl<'de> Visitor<'de> for EnumVisitor {
2487            type Value = GetMetadataAsyncCheckResult;
2488            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2489                f.write_str("a GetMetadataAsyncCheckResult structure")
2490            }
2491            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2492                let tag: &str = match map.next_key()? {
2493                    Some(".tag") => map.next_value()?,
2494                    _ => return Err(de::Error::missing_field(".tag"))
2495                };
2496                let value = match tag {
2497                    "in_progress" => GetMetadataAsyncCheckResult::InProgress,
2498                    "complete" => GetMetadataAsyncCheckResult::Complete(GetMetadataResult::internal_deserialize(&mut map)?),
2499                    "failed" => GetMetadataAsyncCheckResult::Failed(GetMetadataAsyncError::internal_deserialize(&mut map)?),
2500                    _ => GetMetadataAsyncCheckResult::Other,
2501                };
2502                crate::eat_json_fields(&mut map)?;
2503                Ok(value)
2504            }
2505        }
2506        const VARIANTS: &[&str] = &["in_progress",
2507                                    "complete",
2508                                    "failed",
2509                                    "other"];
2510        deserializer.deserialize_struct("GetMetadataAsyncCheckResult", VARIANTS, EnumVisitor)
2511    }
2512}
2513
2514impl ::serde::ser::Serialize for GetMetadataAsyncCheckResult {
2515    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2516        // union serializer
2517        use serde::ser::SerializeStruct;
2518        match self {
2519            GetMetadataAsyncCheckResult::InProgress => {
2520                // unit
2521                let mut s = serializer.serialize_struct("GetMetadataAsyncCheckResult", 1)?;
2522                s.serialize_field(".tag", "in_progress")?;
2523                s.end()
2524            }
2525            GetMetadataAsyncCheckResult::Complete(x) => {
2526                // struct
2527                let mut s = serializer.serialize_struct("GetMetadataAsyncCheckResult", 3)?;
2528                s.serialize_field(".tag", "complete")?;
2529                x.internal_serialize::<S>(&mut s)?;
2530                s.end()
2531            }
2532            GetMetadataAsyncCheckResult::Failed(x) => {
2533                // struct
2534                let mut s = serializer.serialize_struct("GetMetadataAsyncCheckResult", 3)?;
2535                s.serialize_field(".tag", "failed")?;
2536                x.internal_serialize::<S>(&mut s)?;
2537                s.end()
2538            }
2539            GetMetadataAsyncCheckResult::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2540        }
2541    }
2542}
2543
2544#[derive(Debug, Clone, PartialEq, Eq)]
2545#[non_exhaustive] // structs may have more fields added in the future.
2546pub struct GetMetadataAsyncError {
2547    pub error_code: ErrorCode,
2548    pub error_details: Option<MetadataExtractionApiV2Error>,
2549}
2550
2551impl Default for GetMetadataAsyncError {
2552    fn default() -> Self {
2553        GetMetadataAsyncError {
2554            error_code: ErrorCode::UnknownError,
2555            error_details: None,
2556        }
2557    }
2558}
2559
2560impl GetMetadataAsyncError {
2561    pub fn with_error_code(mut self, value: ErrorCode) -> Self {
2562        self.error_code = value;
2563        self
2564    }
2565
2566    pub fn with_error_details(mut self, value: MetadataExtractionApiV2Error) -> Self {
2567        self.error_details = Some(value);
2568        self
2569    }
2570}
2571
2572const GET_METADATA_ASYNC_ERROR_FIELDS: &[&str] = &["error_code",
2573                                                   "error_details"];
2574impl GetMetadataAsyncError {
2575    // no _opt deserializer
2576    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2577        mut map: V,
2578    ) -> Result<GetMetadataAsyncError, V::Error> {
2579        let mut field_error_code = None;
2580        let mut field_error_details = None;
2581        while let Some(key) = map.next_key::<&str>()? {
2582            match key {
2583                "error_code" => {
2584                    if field_error_code.is_some() {
2585                        return Err(::serde::de::Error::duplicate_field("error_code"));
2586                    }
2587                    field_error_code = Some(map.next_value()?);
2588                }
2589                "error_details" => {
2590                    if field_error_details.is_some() {
2591                        return Err(::serde::de::Error::duplicate_field("error_details"));
2592                    }
2593                    field_error_details = Some(map.next_value()?);
2594                }
2595                _ => {
2596                    // unknown field allowed and ignored
2597                    map.next_value::<::serde_json::Value>()?;
2598                }
2599            }
2600        }
2601        let result = GetMetadataAsyncError {
2602            error_code: field_error_code.unwrap_or(ErrorCode::UnknownError),
2603            error_details: field_error_details.and_then(Option::flatten),
2604        };
2605        Ok(result)
2606    }
2607
2608    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2609        &self,
2610        s: &mut S::SerializeStruct,
2611    ) -> Result<(), S::Error> {
2612        use serde::ser::SerializeStruct;
2613        if self.error_code != ErrorCode::UnknownError {
2614            s.serialize_field("error_code", &self.error_code)?;
2615        }
2616        if let Some(val) = &self.error_details {
2617            s.serialize_field("error_details", val)?;
2618        }
2619        Ok(())
2620    }
2621}
2622
2623impl<'de> ::serde::de::Deserialize<'de> for GetMetadataAsyncError {
2624    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2625        // struct deserializer
2626        use serde::de::{MapAccess, Visitor};
2627        struct StructVisitor;
2628        impl<'de> Visitor<'de> for StructVisitor {
2629            type Value = GetMetadataAsyncError;
2630            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2631                f.write_str("a GetMetadataAsyncError struct")
2632            }
2633            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2634                GetMetadataAsyncError::internal_deserialize(map)
2635            }
2636        }
2637        deserializer.deserialize_struct("GetMetadataAsyncError", GET_METADATA_ASYNC_ERROR_FIELDS, StructVisitor)
2638    }
2639}
2640
2641impl ::serde::ser::Serialize for GetMetadataAsyncError {
2642    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2643        // struct serializer
2644        use serde::ser::SerializeStruct;
2645        let mut s = serializer.serialize_struct("GetMetadataAsyncError", 2)?;
2646        self.internal_serialize::<S>(&mut s)?;
2647        s.end()
2648    }
2649}
2650
2651#[derive(Debug, Clone, PartialEq)]
2652#[non_exhaustive] // structs may have more fields added in the future.
2653pub struct GetMetadataResult {
2654    /// The kind of metadata that was extracted for the requested file. Callers should read the
2655    /// matching field of the `metadata` oneof.
2656    pub metadata_type: MetadataType,
2657    pub metadata: Option<MetadataUnion>,
2658}
2659
2660impl Default for GetMetadataResult {
2661    fn default() -> Self {
2662        GetMetadataResult {
2663            metadata_type: MetadataType::MetadataTypeUnknown,
2664            metadata: None,
2665        }
2666    }
2667}
2668
2669impl GetMetadataResult {
2670    pub fn with_metadata_type(mut self, value: MetadataType) -> Self {
2671        self.metadata_type = value;
2672        self
2673    }
2674
2675    pub fn with_metadata(mut self, value: MetadataUnion) -> Self {
2676        self.metadata = Some(value);
2677        self
2678    }
2679}
2680
2681const GET_METADATA_RESULT_FIELDS: &[&str] = &["metadata_type",
2682                                              "metadata"];
2683impl GetMetadataResult {
2684    // no _opt deserializer
2685    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2686        mut map: V,
2687    ) -> Result<GetMetadataResult, V::Error> {
2688        let mut field_metadata_type = None;
2689        let mut field_metadata = None;
2690        while let Some(key) = map.next_key::<&str>()? {
2691            match key {
2692                "metadata_type" => {
2693                    if field_metadata_type.is_some() {
2694                        return Err(::serde::de::Error::duplicate_field("metadata_type"));
2695                    }
2696                    field_metadata_type = Some(map.next_value()?);
2697                }
2698                "metadata" => {
2699                    if field_metadata.is_some() {
2700                        return Err(::serde::de::Error::duplicate_field("metadata"));
2701                    }
2702                    field_metadata = Some(map.next_value()?);
2703                }
2704                _ => {
2705                    // unknown field allowed and ignored
2706                    map.next_value::<::serde_json::Value>()?;
2707                }
2708            }
2709        }
2710        let result = GetMetadataResult {
2711            metadata_type: field_metadata_type.unwrap_or(MetadataType::MetadataTypeUnknown),
2712            metadata: field_metadata.and_then(Option::flatten),
2713        };
2714        Ok(result)
2715    }
2716
2717    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2718        &self,
2719        s: &mut S::SerializeStruct,
2720    ) -> Result<(), S::Error> {
2721        use serde::ser::SerializeStruct;
2722        if self.metadata_type != MetadataType::MetadataTypeUnknown {
2723            s.serialize_field("metadata_type", &self.metadata_type)?;
2724        }
2725        if let Some(val) = &self.metadata {
2726            s.serialize_field("metadata", val)?;
2727        }
2728        Ok(())
2729    }
2730}
2731
2732impl<'de> ::serde::de::Deserialize<'de> for GetMetadataResult {
2733    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2734        // struct deserializer
2735        use serde::de::{MapAccess, Visitor};
2736        struct StructVisitor;
2737        impl<'de> Visitor<'de> for StructVisitor {
2738            type Value = GetMetadataResult;
2739            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2740                f.write_str("a GetMetadataResult struct")
2741            }
2742            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2743                GetMetadataResult::internal_deserialize(map)
2744            }
2745        }
2746        deserializer.deserialize_struct("GetMetadataResult", GET_METADATA_RESULT_FIELDS, StructVisitor)
2747    }
2748}
2749
2750impl ::serde::ser::Serialize for GetMetadataResult {
2751    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2752        // struct serializer
2753        use serde::ser::SerializeStruct;
2754        let mut s = serializer.serialize_struct("GetMetadataResult", 2)?;
2755        self.internal_serialize::<S>(&mut s)?;
2756        s.end()
2757    }
2758}
2759
2760/// Arguments for the asynchronous `get_transcript_async` route. Exactly one of `file_id`, `path`,
2761/// or `url` must be supplied via `file_id_or_url` to identify the audio or video asset to
2762/// transcribe.
2763#[derive(Debug, Clone, PartialEq, Eq)]
2764#[non_exhaustive] // structs may have more fields added in the future.
2765pub struct GetTranscriptArgs {
2766    /// Identifier of the media asset to transcribe. Callers must set exactly one of the oneof
2767    /// variants: - file_id: a Dropbox-issued file id (format: "id:<id>") for a file the
2768    /// authenticated user has access to. - path: an absolute Dropbox path, e.g.
2769    /// "/folder/recording.mp4". - url: either a Dropbox shared link (www.dropbox.com) or an
2770    /// external HTTPS URL pointing to a supported audio/video file. - Dropbox shared links are
2771    /// resolved internally using the caller's authenticated identity and the link's visibility /
2772    /// download settings. They therefore require an authenticated user context (anonymous `url`
2773    /// requests against Dropbox links are rejected with an `ACCESS_ERROR`). Links protected by a
2774    /// password are rejected with `shared_link_password_protected`; links with downloads disabled
2775    /// are rejected with `link_download_disabled_error`. - External URLs are fetched over HTTPS
2776    /// through the backend's egress proxy and must point at a supported audio/video file extension.
2777    /// The referenced asset must be an audio or video file in a supported format; requests against
2778    /// files with no audio track return a `no_audio_error`.
2779    pub file_id_or_url: Option<FileIdOrUrl>,
2780    /// Granularity of the time offsets returned for each transcript segment. Defaults to `SENTENCE.
2781    /// - SENTENCE: one segment per spoken sentence (recommended). - WORD: one segment per word,
2782    /// useful for fine-grained alignment such as captioning or highlight-as-you-listen experiences.
2783    pub timestamp_level: TimestampLevel,
2784    /// Comma-delimited list of non-lexical filler words to preserve in the transcript output, e.g.
2785    /// `"uh, ah, uhm"`. By default these fillers are stripped. Unrecognized tokens are ignored.
2786    /// Leave empty to use the default filtering behavior.
2787    pub included_special_words: String,
2788    /// Optional ISO 639-1 two-letter language code hinting the spoken language of the source audio
2789    /// (e.g. "en", "ja"). When empty, the service auto-detects the language; supplying a hint
2790    /// improves accuracy and latency for short or ambiguous clips. Unsupported languages fall back
2791    /// to auto-detection.
2792    pub audio_language: String,
2793}
2794
2795impl Default for GetTranscriptArgs {
2796    fn default() -> Self {
2797        GetTranscriptArgs {
2798            file_id_or_url: None,
2799            timestamp_level: TimestampLevel::Unknown,
2800            included_special_words: String::new(),
2801            audio_language: String::new(),
2802        }
2803    }
2804}
2805
2806impl GetTranscriptArgs {
2807    pub fn with_file_id_or_url(mut self, value: FileIdOrUrl) -> Self {
2808        self.file_id_or_url = Some(value);
2809        self
2810    }
2811
2812    pub fn with_timestamp_level(mut self, value: TimestampLevel) -> Self {
2813        self.timestamp_level = value;
2814        self
2815    }
2816
2817    pub fn with_included_special_words(mut self, value: String) -> Self {
2818        self.included_special_words = value;
2819        self
2820    }
2821
2822    pub fn with_audio_language(mut self, value: String) -> Self {
2823        self.audio_language = value;
2824        self
2825    }
2826}
2827
2828const GET_TRANSCRIPT_ARGS_FIELDS: &[&str] = &["file_id_or_url",
2829                                              "timestamp_level",
2830                                              "included_special_words",
2831                                              "audio_language"];
2832impl GetTranscriptArgs {
2833    // no _opt deserializer
2834    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2835        mut map: V,
2836    ) -> Result<GetTranscriptArgs, V::Error> {
2837        let mut field_file_id_or_url = None;
2838        let mut field_timestamp_level = None;
2839        let mut field_included_special_words = None;
2840        let mut field_audio_language = None;
2841        while let Some(key) = map.next_key::<&str>()? {
2842            match key {
2843                "file_id_or_url" => {
2844                    if field_file_id_or_url.is_some() {
2845                        return Err(::serde::de::Error::duplicate_field("file_id_or_url"));
2846                    }
2847                    field_file_id_or_url = Some(map.next_value()?);
2848                }
2849                "timestamp_level" => {
2850                    if field_timestamp_level.is_some() {
2851                        return Err(::serde::de::Error::duplicate_field("timestamp_level"));
2852                    }
2853                    field_timestamp_level = Some(map.next_value()?);
2854                }
2855                "included_special_words" => {
2856                    if field_included_special_words.is_some() {
2857                        return Err(::serde::de::Error::duplicate_field("included_special_words"));
2858                    }
2859                    field_included_special_words = Some(map.next_value()?);
2860                }
2861                "audio_language" => {
2862                    if field_audio_language.is_some() {
2863                        return Err(::serde::de::Error::duplicate_field("audio_language"));
2864                    }
2865                    field_audio_language = Some(map.next_value()?);
2866                }
2867                _ => {
2868                    // unknown field allowed and ignored
2869                    map.next_value::<::serde_json::Value>()?;
2870                }
2871            }
2872        }
2873        let result = GetTranscriptArgs {
2874            file_id_or_url: field_file_id_or_url.and_then(Option::flatten),
2875            timestamp_level: field_timestamp_level.unwrap_or(TimestampLevel::Unknown),
2876            included_special_words: field_included_special_words.unwrap_or_default(),
2877            audio_language: field_audio_language.unwrap_or_default(),
2878        };
2879        Ok(result)
2880    }
2881
2882    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2883        &self,
2884        s: &mut S::SerializeStruct,
2885    ) -> Result<(), S::Error> {
2886        use serde::ser::SerializeStruct;
2887        if let Some(val) = &self.file_id_or_url {
2888            s.serialize_field("file_id_or_url", val)?;
2889        }
2890        if self.timestamp_level != TimestampLevel::Unknown {
2891            s.serialize_field("timestamp_level", &self.timestamp_level)?;
2892        }
2893        if !self.included_special_words.is_empty() {
2894            s.serialize_field("included_special_words", &self.included_special_words)?;
2895        }
2896        if !self.audio_language.is_empty() {
2897            s.serialize_field("audio_language", &self.audio_language)?;
2898        }
2899        Ok(())
2900    }
2901}
2902
2903impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptArgs {
2904    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2905        // struct deserializer
2906        use serde::de::{MapAccess, Visitor};
2907        struct StructVisitor;
2908        impl<'de> Visitor<'de> for StructVisitor {
2909            type Value = GetTranscriptArgs;
2910            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2911                f.write_str("a GetTranscriptArgs struct")
2912            }
2913            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2914                GetTranscriptArgs::internal_deserialize(map)
2915            }
2916        }
2917        deserializer.deserialize_struct("GetTranscriptArgs", GET_TRANSCRIPT_ARGS_FIELDS, StructVisitor)
2918    }
2919}
2920
2921impl ::serde::ser::Serialize for GetTranscriptArgs {
2922    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2923        // struct serializer
2924        use serde::ser::SerializeStruct;
2925        let mut s = serializer.serialize_struct("GetTranscriptArgs", 4)?;
2926        self.internal_serialize::<S>(&mut s)?;
2927        s.end()
2928    }
2929}
2930
2931/// Result type for EventBus async check - must end in "CheckResult"
2932#[derive(Debug, Clone, PartialEq)]
2933#[non_exhaustive] // variants may be added in the future
2934pub enum GetTranscriptAsyncCheckResult {
2935    InProgress,
2936    Complete(GetTranscriptResult),
2937    Failed(GetTranscriptAsyncError),
2938    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2939    /// typically indicates that this SDK version is out of date.
2940    Other,
2941}
2942
2943impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptAsyncCheckResult {
2944    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2945        // union deserializer
2946        use serde::de::{self, MapAccess, Visitor};
2947        struct EnumVisitor;
2948        impl<'de> Visitor<'de> for EnumVisitor {
2949            type Value = GetTranscriptAsyncCheckResult;
2950            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2951                f.write_str("a GetTranscriptAsyncCheckResult structure")
2952            }
2953            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2954                let tag: &str = match map.next_key()? {
2955                    Some(".tag") => map.next_value()?,
2956                    _ => return Err(de::Error::missing_field(".tag"))
2957                };
2958                let value = match tag {
2959                    "in_progress" => GetTranscriptAsyncCheckResult::InProgress,
2960                    "complete" => GetTranscriptAsyncCheckResult::Complete(GetTranscriptResult::internal_deserialize(&mut map)?),
2961                    "failed" => GetTranscriptAsyncCheckResult::Failed(GetTranscriptAsyncError::internal_deserialize(&mut map)?),
2962                    _ => GetTranscriptAsyncCheckResult::Other,
2963                };
2964                crate::eat_json_fields(&mut map)?;
2965                Ok(value)
2966            }
2967        }
2968        const VARIANTS: &[&str] = &["in_progress",
2969                                    "complete",
2970                                    "failed",
2971                                    "other"];
2972        deserializer.deserialize_struct("GetTranscriptAsyncCheckResult", VARIANTS, EnumVisitor)
2973    }
2974}
2975
2976impl ::serde::ser::Serialize for GetTranscriptAsyncCheckResult {
2977    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2978        // union serializer
2979        use serde::ser::SerializeStruct;
2980        match self {
2981            GetTranscriptAsyncCheckResult::InProgress => {
2982                // unit
2983                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 1)?;
2984                s.serialize_field(".tag", "in_progress")?;
2985                s.end()
2986            }
2987            GetTranscriptAsyncCheckResult::Complete(x) => {
2988                // struct
2989                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 2)?;
2990                s.serialize_field(".tag", "complete")?;
2991                x.internal_serialize::<S>(&mut s)?;
2992                s.end()
2993            }
2994            GetTranscriptAsyncCheckResult::Failed(x) => {
2995                // struct
2996                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 3)?;
2997                s.serialize_field(".tag", "failed")?;
2998                x.internal_serialize::<S>(&mut s)?;
2999                s.end()
3000            }
3001            GetTranscriptAsyncCheckResult::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3002        }
3003    }
3004}
3005
3006#[derive(Debug, Clone, PartialEq, Eq)]
3007#[non_exhaustive] // structs may have more fields added in the future.
3008pub struct GetTranscriptAsyncError {
3009    pub error_code: ErrorCode,
3010    pub error_details: Option<ContentApiV2Error>,
3011}
3012
3013impl Default for GetTranscriptAsyncError {
3014    fn default() -> Self {
3015        GetTranscriptAsyncError {
3016            error_code: ErrorCode::UnknownError,
3017            error_details: None,
3018        }
3019    }
3020}
3021
3022impl GetTranscriptAsyncError {
3023    pub fn with_error_code(mut self, value: ErrorCode) -> Self {
3024        self.error_code = value;
3025        self
3026    }
3027
3028    pub fn with_error_details(mut self, value: ContentApiV2Error) -> Self {
3029        self.error_details = Some(value);
3030        self
3031    }
3032}
3033
3034const GET_TRANSCRIPT_ASYNC_ERROR_FIELDS: &[&str] = &["error_code",
3035                                                     "error_details"];
3036impl GetTranscriptAsyncError {
3037    // no _opt deserializer
3038    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3039        mut map: V,
3040    ) -> Result<GetTranscriptAsyncError, V::Error> {
3041        let mut field_error_code = None;
3042        let mut field_error_details = None;
3043        while let Some(key) = map.next_key::<&str>()? {
3044            match key {
3045                "error_code" => {
3046                    if field_error_code.is_some() {
3047                        return Err(::serde::de::Error::duplicate_field("error_code"));
3048                    }
3049                    field_error_code = Some(map.next_value()?);
3050                }
3051                "error_details" => {
3052                    if field_error_details.is_some() {
3053                        return Err(::serde::de::Error::duplicate_field("error_details"));
3054                    }
3055                    field_error_details = Some(map.next_value()?);
3056                }
3057                _ => {
3058                    // unknown field allowed and ignored
3059                    map.next_value::<::serde_json::Value>()?;
3060                }
3061            }
3062        }
3063        let result = GetTranscriptAsyncError {
3064            error_code: field_error_code.unwrap_or(ErrorCode::UnknownError),
3065            error_details: field_error_details.and_then(Option::flatten),
3066        };
3067        Ok(result)
3068    }
3069
3070    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3071        &self,
3072        s: &mut S::SerializeStruct,
3073    ) -> Result<(), S::Error> {
3074        use serde::ser::SerializeStruct;
3075        if self.error_code != ErrorCode::UnknownError {
3076            s.serialize_field("error_code", &self.error_code)?;
3077        }
3078        if let Some(val) = &self.error_details {
3079            s.serialize_field("error_details", val)?;
3080        }
3081        Ok(())
3082    }
3083}
3084
3085impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptAsyncError {
3086    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3087        // struct deserializer
3088        use serde::de::{MapAccess, Visitor};
3089        struct StructVisitor;
3090        impl<'de> Visitor<'de> for StructVisitor {
3091            type Value = GetTranscriptAsyncError;
3092            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3093                f.write_str("a GetTranscriptAsyncError struct")
3094            }
3095            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3096                GetTranscriptAsyncError::internal_deserialize(map)
3097            }
3098        }
3099        deserializer.deserialize_struct("GetTranscriptAsyncError", GET_TRANSCRIPT_ASYNC_ERROR_FIELDS, StructVisitor)
3100    }
3101}
3102
3103impl ::serde::ser::Serialize for GetTranscriptAsyncError {
3104    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3105        // struct serializer
3106        use serde::ser::SerializeStruct;
3107        let mut s = serializer.serialize_struct("GetTranscriptAsyncError", 2)?;
3108        self.internal_serialize::<S>(&mut s)?;
3109        s.end()
3110    }
3111}
3112
3113#[derive(Debug, Clone, PartialEq, Default)]
3114#[non_exhaustive] // structs may have more fields added in the future.
3115pub struct GetTranscriptResult {
3116    /// The structured transcript produced for the requested media asset, with per-segment text,
3117    /// start/end offsets (in seconds from the beginning of the media), and the detected or
3118    /// caller-supplied locale.
3119    pub structured_transcript: Option<ApiStructuredTranscript>,
3120}
3121
3122impl GetTranscriptResult {
3123    pub fn with_structured_transcript(mut self, value: ApiStructuredTranscript) -> Self {
3124        self.structured_transcript = Some(value);
3125        self
3126    }
3127}
3128
3129const GET_TRANSCRIPT_RESULT_FIELDS: &[&str] = &["structured_transcript"];
3130impl GetTranscriptResult {
3131    // no _opt deserializer
3132    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3133        mut map: V,
3134    ) -> Result<GetTranscriptResult, V::Error> {
3135        let mut field_structured_transcript = None;
3136        while let Some(key) = map.next_key::<&str>()? {
3137            match key {
3138                "structured_transcript" => {
3139                    if field_structured_transcript.is_some() {
3140                        return Err(::serde::de::Error::duplicate_field("structured_transcript"));
3141                    }
3142                    field_structured_transcript = Some(map.next_value()?);
3143                }
3144                _ => {
3145                    // unknown field allowed and ignored
3146                    map.next_value::<::serde_json::Value>()?;
3147                }
3148            }
3149        }
3150        let result = GetTranscriptResult {
3151            structured_transcript: field_structured_transcript.and_then(Option::flatten),
3152        };
3153        Ok(result)
3154    }
3155
3156    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3157        &self,
3158        s: &mut S::SerializeStruct,
3159    ) -> Result<(), S::Error> {
3160        use serde::ser::SerializeStruct;
3161        if let Some(val) = &self.structured_transcript {
3162            s.serialize_field("structured_transcript", val)?;
3163        }
3164        Ok(())
3165    }
3166}
3167
3168impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptResult {
3169    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3170        // struct deserializer
3171        use serde::de::{MapAccess, Visitor};
3172        struct StructVisitor;
3173        impl<'de> Visitor<'de> for StructVisitor {
3174            type Value = GetTranscriptResult;
3175            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3176                f.write_str("a GetTranscriptResult struct")
3177            }
3178            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3179                GetTranscriptResult::internal_deserialize(map)
3180            }
3181        }
3182        deserializer.deserialize_struct("GetTranscriptResult", GET_TRANSCRIPT_RESULT_FIELDS, StructVisitor)
3183    }
3184}
3185
3186impl ::serde::ser::Serialize for GetTranscriptResult {
3187    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3188        // struct serializer
3189        use serde::ser::SerializeStruct;
3190        let mut s = serializer.serialize_struct("GetTranscriptResult", 1)?;
3191        self.internal_serialize::<S>(&mut s)?;
3192        s.end()
3193    }
3194}
3195
3196#[derive(Debug, Clone, PartialEq, Eq)]
3197#[non_exhaustive] // variants may be added in the future
3198pub enum MarkdownConversionApiV2Error {
3199    ServerError(String),
3200    UserError(String),
3201    UnsupportedFormatError,
3202    LinkDownloadDisabledError,
3203    SharedLinkPasswordProtected,
3204    LimitExceededError,
3205    ConversionFailureError,
3206    /// The referenced file does not exist or is not accessible.
3207    NotFoundError,
3208    /// The target is a folder, not a file.
3209    IsAFolderError,
3210    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3211    /// typically indicates that this SDK version is out of date.
3212    Other,
3213}
3214
3215impl<'de> ::serde::de::Deserialize<'de> for MarkdownConversionApiV2Error {
3216    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3217        // union deserializer
3218        use serde::de::{self, MapAccess, Visitor};
3219        struct EnumVisitor;
3220        impl<'de> Visitor<'de> for EnumVisitor {
3221            type Value = MarkdownConversionApiV2Error;
3222            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3223                f.write_str("a MarkdownConversionApiV2Error structure")
3224            }
3225            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3226                let tag: &str = match map.next_key()? {
3227                    Some(".tag") => map.next_value()?,
3228                    _ => return Err(de::Error::missing_field(".tag"))
3229                };
3230                let value = match tag {
3231                    "server_error" => {
3232                        match map.next_key()? {
3233                            Some("server_error") => MarkdownConversionApiV2Error::ServerError(map.next_value()?),
3234                            None => return Err(de::Error::missing_field("server_error")),
3235                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3236                        }
3237                    }
3238                    "user_error" => {
3239                        match map.next_key()? {
3240                            Some("user_error") => MarkdownConversionApiV2Error::UserError(map.next_value()?),
3241                            None => return Err(de::Error::missing_field("user_error")),
3242                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3243                        }
3244                    }
3245                    "unsupported_format_error" => MarkdownConversionApiV2Error::UnsupportedFormatError,
3246                    "link_download_disabled_error" => MarkdownConversionApiV2Error::LinkDownloadDisabledError,
3247                    "shared_link_password_protected" => MarkdownConversionApiV2Error::SharedLinkPasswordProtected,
3248                    "limit_exceeded_error" => MarkdownConversionApiV2Error::LimitExceededError,
3249                    "conversion_failure_error" => MarkdownConversionApiV2Error::ConversionFailureError,
3250                    "not_found_error" => MarkdownConversionApiV2Error::NotFoundError,
3251                    "is_a_folder_error" => MarkdownConversionApiV2Error::IsAFolderError,
3252                    _ => MarkdownConversionApiV2Error::Other,
3253                };
3254                crate::eat_json_fields(&mut map)?;
3255                Ok(value)
3256            }
3257        }
3258        const VARIANTS: &[&str] = &["server_error",
3259                                    "user_error",
3260                                    "unsupported_format_error",
3261                                    "link_download_disabled_error",
3262                                    "shared_link_password_protected",
3263                                    "limit_exceeded_error",
3264                                    "conversion_failure_error",
3265                                    "not_found_error",
3266                                    "is_a_folder_error",
3267                                    "other"];
3268        deserializer.deserialize_struct("MarkdownConversionApiV2Error", VARIANTS, EnumVisitor)
3269    }
3270}
3271
3272impl ::serde::ser::Serialize for MarkdownConversionApiV2Error {
3273    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3274        // union serializer
3275        use serde::ser::SerializeStruct;
3276        match self {
3277            MarkdownConversionApiV2Error::ServerError(x) => {
3278                // primitive
3279                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 2)?;
3280                s.serialize_field(".tag", "server_error")?;
3281                s.serialize_field("server_error", x)?;
3282                s.end()
3283            }
3284            MarkdownConversionApiV2Error::UserError(x) => {
3285                // primitive
3286                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 2)?;
3287                s.serialize_field(".tag", "user_error")?;
3288                s.serialize_field("user_error", x)?;
3289                s.end()
3290            }
3291            MarkdownConversionApiV2Error::UnsupportedFormatError => {
3292                // unit
3293                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
3294                s.serialize_field(".tag", "unsupported_format_error")?;
3295                s.end()
3296            }
3297            MarkdownConversionApiV2Error::LinkDownloadDisabledError => {
3298                // unit
3299                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
3300                s.serialize_field(".tag", "link_download_disabled_error")?;
3301                s.end()
3302            }
3303            MarkdownConversionApiV2Error::SharedLinkPasswordProtected => {
3304                // unit
3305                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
3306                s.serialize_field(".tag", "shared_link_password_protected")?;
3307                s.end()
3308            }
3309            MarkdownConversionApiV2Error::LimitExceededError => {
3310                // unit
3311                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
3312                s.serialize_field(".tag", "limit_exceeded_error")?;
3313                s.end()
3314            }
3315            MarkdownConversionApiV2Error::ConversionFailureError => {
3316                // unit
3317                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
3318                s.serialize_field(".tag", "conversion_failure_error")?;
3319                s.end()
3320            }
3321            MarkdownConversionApiV2Error::NotFoundError => {
3322                // unit
3323                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
3324                s.serialize_field(".tag", "not_found_error")?;
3325                s.end()
3326            }
3327            MarkdownConversionApiV2Error::IsAFolderError => {
3328                // unit
3329                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
3330                s.serialize_field(".tag", "is_a_folder_error")?;
3331                s.end()
3332            }
3333            MarkdownConversionApiV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3334        }
3335    }
3336}
3337
3338impl ::std::error::Error for MarkdownConversionApiV2Error {
3339}
3340
3341impl ::std::fmt::Display for MarkdownConversionApiV2Error {
3342    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3343        match self {
3344            MarkdownConversionApiV2Error::ServerError(inner) => write!(f, "server_error: {:?}", inner),
3345            MarkdownConversionApiV2Error::UserError(inner) => write!(f, "user_error: {:?}", inner),
3346            MarkdownConversionApiV2Error::NotFoundError => f.write_str("The referenced file does not exist or is not accessible."),
3347            MarkdownConversionApiV2Error::IsAFolderError => f.write_str("The target is a folder, not a file."),
3348            _ => write!(f, "{:?}", *self),
3349        }
3350    }
3351}
3352
3353#[derive(Debug, Clone, PartialEq, Eq, Default)]
3354#[non_exhaustive] // structs may have more fields added in the future.
3355pub struct MediaDurationError {
3356    pub limit: i32,
3357}
3358
3359impl MediaDurationError {
3360    pub fn with_limit(mut self, value: i32) -> Self {
3361        self.limit = value;
3362        self
3363    }
3364}
3365
3366const MEDIA_DURATION_ERROR_FIELDS: &[&str] = &["limit"];
3367impl MediaDurationError {
3368    // no _opt deserializer
3369    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3370        mut map: V,
3371    ) -> Result<MediaDurationError, V::Error> {
3372        let mut field_limit = None;
3373        while let Some(key) = map.next_key::<&str>()? {
3374            match key {
3375                "limit" => {
3376                    if field_limit.is_some() {
3377                        return Err(::serde::de::Error::duplicate_field("limit"));
3378                    }
3379                    field_limit = Some(map.next_value()?);
3380                }
3381                _ => {
3382                    // unknown field allowed and ignored
3383                    map.next_value::<::serde_json::Value>()?;
3384                }
3385            }
3386        }
3387        let result = MediaDurationError {
3388            limit: field_limit.unwrap_or(0),
3389        };
3390        Ok(result)
3391    }
3392
3393    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3394        &self,
3395        s: &mut S::SerializeStruct,
3396    ) -> Result<(), S::Error> {
3397        use serde::ser::SerializeStruct;
3398        if self.limit != 0 {
3399            s.serialize_field("limit", &self.limit)?;
3400        }
3401        Ok(())
3402    }
3403}
3404
3405impl<'de> ::serde::de::Deserialize<'de> for MediaDurationError {
3406    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3407        // struct deserializer
3408        use serde::de::{MapAccess, Visitor};
3409        struct StructVisitor;
3410        impl<'de> Visitor<'de> for StructVisitor {
3411            type Value = MediaDurationError;
3412            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3413                f.write_str("a MediaDurationError struct")
3414            }
3415            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3416                MediaDurationError::internal_deserialize(map)
3417            }
3418        }
3419        deserializer.deserialize_struct("MediaDurationError", MEDIA_DURATION_ERROR_FIELDS, StructVisitor)
3420    }
3421}
3422
3423impl ::serde::ser::Serialize for MediaDurationError {
3424    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3425        // struct serializer
3426        use serde::ser::SerializeStruct;
3427        let mut s = serializer.serialize_struct("MediaDurationError", 1)?;
3428        self.internal_serialize::<S>(&mut s)?;
3429        s.end()
3430    }
3431}
3432
3433#[derive(Debug, Clone, PartialEq, Eq)]
3434#[non_exhaustive] // variants may be added in the future
3435pub enum MetadataExtractionApiV2Error {
3436    ServerError(String),
3437    UserError(String),
3438    UnsupportedFormatError,
3439    LinkDownloadDisabledError,
3440    SharedLinkPasswordProtected,
3441    LimitExceededError,
3442    ConversionFailureError,
3443    /// The referenced file does not exist or is not accessible.
3444    NotFoundError,
3445    /// The target is a folder, not a file.
3446    IsAFolderError,
3447    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3448    /// typically indicates that this SDK version is out of date.
3449    Other,
3450}
3451
3452impl<'de> ::serde::de::Deserialize<'de> for MetadataExtractionApiV2Error {
3453    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3454        // union deserializer
3455        use serde::de::{self, MapAccess, Visitor};
3456        struct EnumVisitor;
3457        impl<'de> Visitor<'de> for EnumVisitor {
3458            type Value = MetadataExtractionApiV2Error;
3459            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3460                f.write_str("a MetadataExtractionApiV2Error structure")
3461            }
3462            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3463                let tag: &str = match map.next_key()? {
3464                    Some(".tag") => map.next_value()?,
3465                    _ => return Err(de::Error::missing_field(".tag"))
3466                };
3467                let value = match tag {
3468                    "server_error" => {
3469                        match map.next_key()? {
3470                            Some("server_error") => MetadataExtractionApiV2Error::ServerError(map.next_value()?),
3471                            None => return Err(de::Error::missing_field("server_error")),
3472                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3473                        }
3474                    }
3475                    "user_error" => {
3476                        match map.next_key()? {
3477                            Some("user_error") => MetadataExtractionApiV2Error::UserError(map.next_value()?),
3478                            None => return Err(de::Error::missing_field("user_error")),
3479                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3480                        }
3481                    }
3482                    "unsupported_format_error" => MetadataExtractionApiV2Error::UnsupportedFormatError,
3483                    "link_download_disabled_error" => MetadataExtractionApiV2Error::LinkDownloadDisabledError,
3484                    "shared_link_password_protected" => MetadataExtractionApiV2Error::SharedLinkPasswordProtected,
3485                    "limit_exceeded_error" => MetadataExtractionApiV2Error::LimitExceededError,
3486                    "conversion_failure_error" => MetadataExtractionApiV2Error::ConversionFailureError,
3487                    "not_found_error" => MetadataExtractionApiV2Error::NotFoundError,
3488                    "is_a_folder_error" => MetadataExtractionApiV2Error::IsAFolderError,
3489                    _ => MetadataExtractionApiV2Error::Other,
3490                };
3491                crate::eat_json_fields(&mut map)?;
3492                Ok(value)
3493            }
3494        }
3495        const VARIANTS: &[&str] = &["server_error",
3496                                    "user_error",
3497                                    "unsupported_format_error",
3498                                    "link_download_disabled_error",
3499                                    "shared_link_password_protected",
3500                                    "limit_exceeded_error",
3501                                    "conversion_failure_error",
3502                                    "not_found_error",
3503                                    "is_a_folder_error",
3504                                    "other"];
3505        deserializer.deserialize_struct("MetadataExtractionApiV2Error", VARIANTS, EnumVisitor)
3506    }
3507}
3508
3509impl ::serde::ser::Serialize for MetadataExtractionApiV2Error {
3510    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3511        // union serializer
3512        use serde::ser::SerializeStruct;
3513        match self {
3514            MetadataExtractionApiV2Error::ServerError(x) => {
3515                // primitive
3516                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 2)?;
3517                s.serialize_field(".tag", "server_error")?;
3518                s.serialize_field("server_error", x)?;
3519                s.end()
3520            }
3521            MetadataExtractionApiV2Error::UserError(x) => {
3522                // primitive
3523                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 2)?;
3524                s.serialize_field(".tag", "user_error")?;
3525                s.serialize_field("user_error", x)?;
3526                s.end()
3527            }
3528            MetadataExtractionApiV2Error::UnsupportedFormatError => {
3529                // unit
3530                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3531                s.serialize_field(".tag", "unsupported_format_error")?;
3532                s.end()
3533            }
3534            MetadataExtractionApiV2Error::LinkDownloadDisabledError => {
3535                // unit
3536                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3537                s.serialize_field(".tag", "link_download_disabled_error")?;
3538                s.end()
3539            }
3540            MetadataExtractionApiV2Error::SharedLinkPasswordProtected => {
3541                // unit
3542                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3543                s.serialize_field(".tag", "shared_link_password_protected")?;
3544                s.end()
3545            }
3546            MetadataExtractionApiV2Error::LimitExceededError => {
3547                // unit
3548                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3549                s.serialize_field(".tag", "limit_exceeded_error")?;
3550                s.end()
3551            }
3552            MetadataExtractionApiV2Error::ConversionFailureError => {
3553                // unit
3554                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3555                s.serialize_field(".tag", "conversion_failure_error")?;
3556                s.end()
3557            }
3558            MetadataExtractionApiV2Error::NotFoundError => {
3559                // unit
3560                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3561                s.serialize_field(".tag", "not_found_error")?;
3562                s.end()
3563            }
3564            MetadataExtractionApiV2Error::IsAFolderError => {
3565                // unit
3566                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3567                s.serialize_field(".tag", "is_a_folder_error")?;
3568                s.end()
3569            }
3570            MetadataExtractionApiV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3571        }
3572    }
3573}
3574
3575impl ::std::error::Error for MetadataExtractionApiV2Error {
3576}
3577
3578impl ::std::fmt::Display for MetadataExtractionApiV2Error {
3579    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3580        match self {
3581            MetadataExtractionApiV2Error::ServerError(inner) => write!(f, "server_error: {:?}", inner),
3582            MetadataExtractionApiV2Error::UserError(inner) => write!(f, "user_error: {:?}", inner),
3583            MetadataExtractionApiV2Error::NotFoundError => f.write_str("The referenced file does not exist or is not accessible."),
3584            MetadataExtractionApiV2Error::IsAFolderError => f.write_str("The target is a folder, not a file."),
3585            _ => write!(f, "{:?}", *self),
3586        }
3587    }
3588}
3589
3590/// Which metadata variant is populated in a `GetMetadataResult`, derived from the file type.
3591#[derive(Debug, Clone, PartialEq, Eq)]
3592#[non_exhaustive] // variants may be added in the future
3593pub enum MetadataType {
3594    MetadataTypeUnknown,
3595    MetadataTypeExif,
3596    MetadataTypeMedia,
3597    MetadataTypePdf,
3598    MetadataTypeOffice,
3599    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3600    /// typically indicates that this SDK version is out of date.
3601    Other,
3602}
3603
3604impl<'de> ::serde::de::Deserialize<'de> for MetadataType {
3605    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3606        // union deserializer
3607        use serde::de::{self, MapAccess, Visitor};
3608        struct EnumVisitor;
3609        impl<'de> Visitor<'de> for EnumVisitor {
3610            type Value = MetadataType;
3611            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3612                f.write_str("a MetadataType structure")
3613            }
3614            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3615                let tag: &str = match map.next_key()? {
3616                    Some(".tag") => map.next_value()?,
3617                    _ => return Err(de::Error::missing_field(".tag"))
3618                };
3619                let value = match tag {
3620                    "metadata_type_unknown" => MetadataType::MetadataTypeUnknown,
3621                    "metadata_type_exif" => MetadataType::MetadataTypeExif,
3622                    "metadata_type_media" => MetadataType::MetadataTypeMedia,
3623                    "metadata_type_pdf" => MetadataType::MetadataTypePdf,
3624                    "metadata_type_office" => MetadataType::MetadataTypeOffice,
3625                    _ => MetadataType::Other,
3626                };
3627                crate::eat_json_fields(&mut map)?;
3628                Ok(value)
3629            }
3630        }
3631        const VARIANTS: &[&str] = &["metadata_type_unknown",
3632                                    "metadata_type_exif",
3633                                    "metadata_type_media",
3634                                    "metadata_type_pdf",
3635                                    "metadata_type_office",
3636                                    "other"];
3637        deserializer.deserialize_struct("MetadataType", VARIANTS, EnumVisitor)
3638    }
3639}
3640
3641impl ::serde::ser::Serialize for MetadataType {
3642    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3643        // union serializer
3644        use serde::ser::SerializeStruct;
3645        match self {
3646            MetadataType::MetadataTypeUnknown => {
3647                // unit
3648                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3649                s.serialize_field(".tag", "metadata_type_unknown")?;
3650                s.end()
3651            }
3652            MetadataType::MetadataTypeExif => {
3653                // unit
3654                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3655                s.serialize_field(".tag", "metadata_type_exif")?;
3656                s.end()
3657            }
3658            MetadataType::MetadataTypeMedia => {
3659                // unit
3660                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3661                s.serialize_field(".tag", "metadata_type_media")?;
3662                s.end()
3663            }
3664            MetadataType::MetadataTypePdf => {
3665                // unit
3666                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3667                s.serialize_field(".tag", "metadata_type_pdf")?;
3668                s.end()
3669            }
3670            MetadataType::MetadataTypeOffice => {
3671                // unit
3672                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3673                s.serialize_field(".tag", "metadata_type_office")?;
3674                s.end()
3675            }
3676            MetadataType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3677        }
3678    }
3679}
3680
3681/// The kind of MS Office document that produced an `ApiOfficeMetadata` result.
3682#[derive(Debug, Clone, PartialEq, Eq)]
3683#[non_exhaustive] // variants may be added in the future
3684pub enum OfficeFileType {
3685    OfficeFiletypeUnknown,
3686    OfficeFiletypeWord,
3687    OfficeFiletypePowerpoint,
3688    OfficeFiletypeExcel,
3689    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3690    /// typically indicates that this SDK version is out of date.
3691    Other,
3692}
3693
3694impl<'de> ::serde::de::Deserialize<'de> for OfficeFileType {
3695    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3696        // union deserializer
3697        use serde::de::{self, MapAccess, Visitor};
3698        struct EnumVisitor;
3699        impl<'de> Visitor<'de> for EnumVisitor {
3700            type Value = OfficeFileType;
3701            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3702                f.write_str("a OfficeFileType structure")
3703            }
3704            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3705                let tag: &str = match map.next_key()? {
3706                    Some(".tag") => map.next_value()?,
3707                    _ => return Err(de::Error::missing_field(".tag"))
3708                };
3709                let value = match tag {
3710                    "office_filetype_unknown" => OfficeFileType::OfficeFiletypeUnknown,
3711                    "office_filetype_word" => OfficeFileType::OfficeFiletypeWord,
3712                    "office_filetype_powerpoint" => OfficeFileType::OfficeFiletypePowerpoint,
3713                    "office_filetype_excel" => OfficeFileType::OfficeFiletypeExcel,
3714                    _ => OfficeFileType::Other,
3715                };
3716                crate::eat_json_fields(&mut map)?;
3717                Ok(value)
3718            }
3719        }
3720        const VARIANTS: &[&str] = &["office_filetype_unknown",
3721                                    "office_filetype_word",
3722                                    "office_filetype_powerpoint",
3723                                    "office_filetype_excel",
3724                                    "other"];
3725        deserializer.deserialize_struct("OfficeFileType", VARIANTS, EnumVisitor)
3726    }
3727}
3728
3729impl ::serde::ser::Serialize for OfficeFileType {
3730    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3731        // union serializer
3732        use serde::ser::SerializeStruct;
3733        match self {
3734            OfficeFileType::OfficeFiletypeUnknown => {
3735                // unit
3736                let mut s = serializer.serialize_struct("OfficeFileType", 1)?;
3737                s.serialize_field(".tag", "office_filetype_unknown")?;
3738                s.end()
3739            }
3740            OfficeFileType::OfficeFiletypeWord => {
3741                // unit
3742                let mut s = serializer.serialize_struct("OfficeFileType", 1)?;
3743                s.serialize_field(".tag", "office_filetype_word")?;
3744                s.end()
3745            }
3746            OfficeFileType::OfficeFiletypePowerpoint => {
3747                // unit
3748                let mut s = serializer.serialize_struct("OfficeFileType", 1)?;
3749                s.serialize_field(".tag", "office_filetype_powerpoint")?;
3750                s.end()
3751            }
3752            OfficeFileType::OfficeFiletypeExcel => {
3753                // unit
3754                let mut s = serializer.serialize_struct("OfficeFileType", 1)?;
3755                s.serialize_field(".tag", "office_filetype_excel")?;
3756                s.end()
3757            }
3758            OfficeFileType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3759        }
3760    }
3761}
3762
3763#[derive(Debug, Clone, PartialEq, Eq)]
3764#[non_exhaustive] // variants may be added in the future
3765pub enum TimestampLevel {
3766    Unknown,
3767    Sentence,
3768    Word,
3769    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3770    /// typically indicates that this SDK version is out of date.
3771    Other,
3772}
3773
3774impl<'de> ::serde::de::Deserialize<'de> for TimestampLevel {
3775    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3776        // union deserializer
3777        use serde::de::{self, MapAccess, Visitor};
3778        struct EnumVisitor;
3779        impl<'de> Visitor<'de> for EnumVisitor {
3780            type Value = TimestampLevel;
3781            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3782                f.write_str("a TimestampLevel structure")
3783            }
3784            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3785                let tag: &str = match map.next_key()? {
3786                    Some(".tag") => map.next_value()?,
3787                    _ => return Err(de::Error::missing_field(".tag"))
3788                };
3789                let value = match tag {
3790                    "unknown" => TimestampLevel::Unknown,
3791                    "sentence" => TimestampLevel::Sentence,
3792                    "word" => TimestampLevel::Word,
3793                    _ => TimestampLevel::Other,
3794                };
3795                crate::eat_json_fields(&mut map)?;
3796                Ok(value)
3797            }
3798        }
3799        const VARIANTS: &[&str] = &["unknown",
3800                                    "sentence",
3801                                    "word",
3802                                    "other"];
3803        deserializer.deserialize_struct("TimestampLevel", VARIANTS, EnumVisitor)
3804    }
3805}
3806
3807impl ::serde::ser::Serialize for TimestampLevel {
3808    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3809        // union serializer
3810        use serde::ser::SerializeStruct;
3811        match self {
3812            TimestampLevel::Unknown => {
3813                // unit
3814                let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
3815                s.serialize_field(".tag", "unknown")?;
3816                s.end()
3817            }
3818            TimestampLevel::Sentence => {
3819                // unit
3820                let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
3821                s.serialize_field(".tag", "sentence")?;
3822                s.end()
3823            }
3824            TimestampLevel::Word => {
3825                // unit
3826                let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
3827                s.serialize_field(".tag", "word")?;
3828                s.end()
3829            }
3830            TimestampLevel::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3831        }
3832    }
3833}
3834
3835/// Exactly one variant is populated, corresponding to `metadata_type`.
3836#[derive(Debug, Clone, PartialEq)]
3837#[non_exhaustive] // variants may be added in the future
3838pub enum MetadataUnion {
3839    Exif(ApiExifMetadata),
3840    Media(ApiMediaMetadata),
3841    Pdf(ApiPdfMetadata),
3842    Office(ApiOfficeMetadata),
3843    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3844    /// typically indicates that this SDK version is out of date.
3845    Other,
3846}
3847
3848impl<'de> ::serde::de::Deserialize<'de> for MetadataUnion {
3849    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3850        // union deserializer
3851        use serde::de::{self, MapAccess, Visitor};
3852        struct EnumVisitor;
3853        impl<'de> Visitor<'de> for EnumVisitor {
3854            type Value = MetadataUnion;
3855            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3856                f.write_str("a metadata_union structure")
3857            }
3858            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3859                let tag: &str = match map.next_key()? {
3860                    Some(".tag") => map.next_value()?,
3861                    _ => return Err(de::Error::missing_field(".tag"))
3862                };
3863                let value = match tag {
3864                    "exif" => MetadataUnion::Exif(ApiExifMetadata::internal_deserialize(&mut map)?),
3865                    "media" => MetadataUnion::Media(ApiMediaMetadata::internal_deserialize(&mut map)?),
3866                    "pdf" => MetadataUnion::Pdf(ApiPdfMetadata::internal_deserialize(&mut map)?),
3867                    "office" => MetadataUnion::Office(ApiOfficeMetadata::internal_deserialize(&mut map)?),
3868                    _ => MetadataUnion::Other,
3869                };
3870                crate::eat_json_fields(&mut map)?;
3871                Ok(value)
3872            }
3873        }
3874        const VARIANTS: &[&str] = &["exif",
3875                                    "media",
3876                                    "pdf",
3877                                    "office",
3878                                    "other"];
3879        deserializer.deserialize_struct("metadata_union", VARIANTS, EnumVisitor)
3880    }
3881}
3882
3883impl ::serde::ser::Serialize for MetadataUnion {
3884    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3885        // union serializer
3886        use serde::ser::SerializeStruct;
3887        match self {
3888            MetadataUnion::Exif(x) => {
3889                // struct
3890                let mut s = serializer.serialize_struct("metadata_union", 17)?;
3891                s.serialize_field(".tag", "exif")?;
3892                x.internal_serialize::<S>(&mut s)?;
3893                s.end()
3894            }
3895            MetadataUnion::Media(x) => {
3896                // struct
3897                let mut s = serializer.serialize_struct("metadata_union", 5)?;
3898                s.serialize_field(".tag", "media")?;
3899                x.internal_serialize::<S>(&mut s)?;
3900                s.end()
3901            }
3902            MetadataUnion::Pdf(x) => {
3903                // struct
3904                let mut s = serializer.serialize_struct("metadata_union", 4)?;
3905                s.serialize_field(".tag", "pdf")?;
3906                x.internal_serialize::<S>(&mut s)?;
3907                s.end()
3908            }
3909            MetadataUnion::Office(x) => {
3910                // struct
3911                let mut s = serializer.serialize_struct("metadata_union", 13)?;
3912                s.serialize_field(".tag", "office")?;
3913                x.internal_serialize::<S>(&mut s)?;
3914                s.end()
3915            }
3916            MetadataUnion::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3917        }
3918    }
3919}
3920