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/// Reason a transcript job failed. Returned in the `failed` variant of
1620/// `GetTranscriptAsyncCheckResult`. This is a semantic error union: the HTTP status of the poll
1621/// request itself is unaffected (a poll that surfaces a failed job is still a normal successful
1622/// poll response). Callers should branch on the variant.
1623#[derive(Debug, Clone, PartialEq, Eq)]
1624#[non_exhaustive] // variants may be added in the future
1625pub enum ContentApiV2Error {
1626    /// An unexpected, typically transient, server-side failure. The string is a human-readable
1627    /// message; retrying with backoff may succeed.
1628    ServerError(String),
1629    /// The request could not be processed as supplied (a problem with the caller's input). The
1630    /// string is a human-readable message; retrying the same request will not help.
1631    UserError(String),
1632    MediaDurationError(MediaDurationError),
1633    NoAudioError,
1634    LinkDownloadDisabledError,
1635    SharedLinkPasswordProtected,
1636    LimitExceededError,
1637    /// The referenced file does not exist or is not accessible.
1638    NotFoundError,
1639    /// The target is a folder, not a file.
1640    IsAFolderError,
1641    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1642    /// typically indicates that this SDK version is out of date.
1643    Other,
1644}
1645
1646impl<'de> ::serde::de::Deserialize<'de> for ContentApiV2Error {
1647    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1648        // union deserializer
1649        use serde::de::{self, MapAccess, Visitor};
1650        struct EnumVisitor;
1651        impl<'de> Visitor<'de> for EnumVisitor {
1652            type Value = ContentApiV2Error;
1653            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1654                f.write_str("a ContentApiV2Error structure")
1655            }
1656            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1657                let tag: &str = match map.next_key()? {
1658                    Some(".tag") => map.next_value()?,
1659                    _ => return Err(de::Error::missing_field(".tag"))
1660                };
1661                let value = match tag {
1662                    "server_error" => {
1663                        match map.next_key()? {
1664                            Some("server_error") => ContentApiV2Error::ServerError(map.next_value()?),
1665                            None => return Err(de::Error::missing_field("server_error")),
1666                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1667                        }
1668                    }
1669                    "user_error" => {
1670                        match map.next_key()? {
1671                            Some("user_error") => ContentApiV2Error::UserError(map.next_value()?),
1672                            None => return Err(de::Error::missing_field("user_error")),
1673                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1674                        }
1675                    }
1676                    "media_duration_error" => ContentApiV2Error::MediaDurationError(MediaDurationError::internal_deserialize(&mut map)?),
1677                    "no_audio_error" => ContentApiV2Error::NoAudioError,
1678                    "link_download_disabled_error" => ContentApiV2Error::LinkDownloadDisabledError,
1679                    "shared_link_password_protected" => ContentApiV2Error::SharedLinkPasswordProtected,
1680                    "limit_exceeded_error" => ContentApiV2Error::LimitExceededError,
1681                    "not_found_error" => ContentApiV2Error::NotFoundError,
1682                    "is_a_folder_error" => ContentApiV2Error::IsAFolderError,
1683                    _ => ContentApiV2Error::Other,
1684                };
1685                crate::eat_json_fields(&mut map)?;
1686                Ok(value)
1687            }
1688        }
1689        const VARIANTS: &[&str] = &["server_error",
1690                                    "user_error",
1691                                    "media_duration_error",
1692                                    "no_audio_error",
1693                                    "link_download_disabled_error",
1694                                    "shared_link_password_protected",
1695                                    "limit_exceeded_error",
1696                                    "not_found_error",
1697                                    "is_a_folder_error",
1698                                    "other"];
1699        deserializer.deserialize_struct("ContentApiV2Error", VARIANTS, EnumVisitor)
1700    }
1701}
1702
1703impl ::serde::ser::Serialize for ContentApiV2Error {
1704    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1705        // union serializer
1706        use serde::ser::SerializeStruct;
1707        match self {
1708            ContentApiV2Error::ServerError(x) => {
1709                // primitive
1710                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
1711                s.serialize_field(".tag", "server_error")?;
1712                s.serialize_field("server_error", x)?;
1713                s.end()
1714            }
1715            ContentApiV2Error::UserError(x) => {
1716                // primitive
1717                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
1718                s.serialize_field(".tag", "user_error")?;
1719                s.serialize_field("user_error", x)?;
1720                s.end()
1721            }
1722            ContentApiV2Error::MediaDurationError(x) => {
1723                // struct
1724                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
1725                s.serialize_field(".tag", "media_duration_error")?;
1726                x.internal_serialize::<S>(&mut s)?;
1727                s.end()
1728            }
1729            ContentApiV2Error::NoAudioError => {
1730                // unit
1731                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1732                s.serialize_field(".tag", "no_audio_error")?;
1733                s.end()
1734            }
1735            ContentApiV2Error::LinkDownloadDisabledError => {
1736                // unit
1737                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1738                s.serialize_field(".tag", "link_download_disabled_error")?;
1739                s.end()
1740            }
1741            ContentApiV2Error::SharedLinkPasswordProtected => {
1742                // unit
1743                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1744                s.serialize_field(".tag", "shared_link_password_protected")?;
1745                s.end()
1746            }
1747            ContentApiV2Error::LimitExceededError => {
1748                // unit
1749                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1750                s.serialize_field(".tag", "limit_exceeded_error")?;
1751                s.end()
1752            }
1753            ContentApiV2Error::NotFoundError => {
1754                // unit
1755                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1756                s.serialize_field(".tag", "not_found_error")?;
1757                s.end()
1758            }
1759            ContentApiV2Error::IsAFolderError => {
1760                // unit
1761                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
1762                s.serialize_field(".tag", "is_a_folder_error")?;
1763                s.end()
1764            }
1765            ContentApiV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1766        }
1767    }
1768}
1769
1770impl ::std::error::Error for ContentApiV2Error {
1771}
1772
1773impl ::std::fmt::Display for ContentApiV2Error {
1774    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1775        match self {
1776            ContentApiV2Error::ServerError(inner) => write!(f, "An unexpected, typically transient, server-side failure. The string is a human-readable message; retrying with backoff may succeed: {:?}", inner),
1777            ContentApiV2Error::UserError(inner) => write!(f, "The request could not be processed as supplied (a problem with the caller's input). The string is a human-readable message; retrying the same request will not help: {:?}", inner),
1778            ContentApiV2Error::MediaDurationError(inner) => write!(f, "media_duration_error: {:?}", inner),
1779            ContentApiV2Error::NotFoundError => f.write_str("The referenced file does not exist or is not accessible."),
1780            ContentApiV2Error::IsAFolderError => f.write_str("The target is a folder, not a file."),
1781            _ => write!(f, "{:?}", *self),
1782        }
1783    }
1784}
1785
1786#[derive(Debug, Clone, PartialEq, Eq)]
1787#[non_exhaustive] // variants may be added in the future
1788pub enum FileIdOrUrl {
1789    /// A Dropbox-issued file id (format: "id:<id>") for a file the authenticated user has access
1790    /// to.
1791    FileId(String),
1792    /// Either a Dropbox shared link (www.dropbox.com) or an external HTTP or HTTPS URL pointing to
1793    /// a supported file. - Dropbox shared links are resolved internally using the caller's
1794    /// authenticated identity and the link's visibility / download settings. They therefore require
1795    /// an authenticated user context (anonymous `url` requests against Dropbox links are rejected
1796    /// with an `access_error`). Links protected by a password are rejected with
1797    /// `shared_link_password_protected`; links with downloads disabled are rejected with
1798    /// `link_download_disabled_error`. - External URLs are fetched through the backend's egress
1799    /// proxy and must point at a supported file extension.
1800    Url(String),
1801    /// An absolute Dropbox path, e.g. "/folder/example.pdf".
1802    Path(String),
1803    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1804    /// typically indicates that this SDK version is out of date.
1805    Other,
1806}
1807
1808impl<'de> ::serde::de::Deserialize<'de> for FileIdOrUrl {
1809    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1810        // union deserializer
1811        use serde::de::{self, MapAccess, Visitor};
1812        struct EnumVisitor;
1813        impl<'de> Visitor<'de> for EnumVisitor {
1814            type Value = FileIdOrUrl;
1815            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1816                f.write_str("a FileIdOrUrl structure")
1817            }
1818            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1819                let tag: &str = match map.next_key()? {
1820                    Some(".tag") => map.next_value()?,
1821                    _ => return Err(de::Error::missing_field(".tag"))
1822                };
1823                let value = match tag {
1824                    "file_id" => {
1825                        match map.next_key()? {
1826                            Some("file_id") => FileIdOrUrl::FileId(map.next_value()?),
1827                            None => return Err(de::Error::missing_field("file_id")),
1828                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1829                        }
1830                    }
1831                    "url" => {
1832                        match map.next_key()? {
1833                            Some("url") => FileIdOrUrl::Url(map.next_value()?),
1834                            None => return Err(de::Error::missing_field("url")),
1835                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1836                        }
1837                    }
1838                    "path" => {
1839                        match map.next_key()? {
1840                            Some("path") => FileIdOrUrl::Path(map.next_value()?),
1841                            None => return Err(de::Error::missing_field("path")),
1842                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1843                        }
1844                    }
1845                    _ => FileIdOrUrl::Other,
1846                };
1847                crate::eat_json_fields(&mut map)?;
1848                Ok(value)
1849            }
1850        }
1851        const VARIANTS: &[&str] = &["file_id",
1852                                    "url",
1853                                    "path",
1854                                    "other"];
1855        deserializer.deserialize_struct("FileIdOrUrl", VARIANTS, EnumVisitor)
1856    }
1857}
1858
1859impl ::serde::ser::Serialize for FileIdOrUrl {
1860    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1861        // union serializer
1862        use serde::ser::SerializeStruct;
1863        match self {
1864            FileIdOrUrl::FileId(x) => {
1865                // primitive
1866                let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
1867                s.serialize_field(".tag", "file_id")?;
1868                s.serialize_field("file_id", x)?;
1869                s.end()
1870            }
1871            FileIdOrUrl::Url(x) => {
1872                // primitive
1873                let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
1874                s.serialize_field(".tag", "url")?;
1875                s.serialize_field("url", x)?;
1876                s.end()
1877            }
1878            FileIdOrUrl::Path(x) => {
1879                // primitive
1880                let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
1881                s.serialize_field(".tag", "path")?;
1882                s.serialize_field("path", x)?;
1883                s.end()
1884            }
1885            FileIdOrUrl::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1886        }
1887    }
1888}
1889
1890/// Arguments for the asynchronous `get_markdown_async` route. Exactly one of `file_id`, `path`, or
1891/// `url` must be supplied via `file_id_or_url` to identify the document to convert to markdown.
1892#[derive(Debug, Clone, PartialEq, Eq, Default)]
1893#[non_exhaustive] // structs may have more fields added in the future.
1894pub struct GetMarkdownArgs {
1895    /// Identifier of the document to convert. Callers must set exactly one of the `FileIdOrUrl`
1896    /// variants. The referenced file must be a document in a supported format (see the route
1897    /// description for the list); requests against unsupported formats return
1898    /// `unsupported_format_error`.
1899    pub file_id_or_url: Option<FileIdOrUrl>,
1900    /// Enable OCR for PDF documents. Processing is slower when enabled.
1901    pub enable_ocr: bool,
1902    /// When true, embed images as base64 data URIs in the markdown output. This can significantly
1903    /// increase output size.
1904    pub embed_images: bool,
1905}
1906
1907impl GetMarkdownArgs {
1908    pub fn with_file_id_or_url(mut self, value: FileIdOrUrl) -> Self {
1909        self.file_id_or_url = Some(value);
1910        self
1911    }
1912
1913    pub fn with_enable_ocr(mut self, value: bool) -> Self {
1914        self.enable_ocr = value;
1915        self
1916    }
1917
1918    pub fn with_embed_images(mut self, value: bool) -> Self {
1919        self.embed_images = value;
1920        self
1921    }
1922}
1923
1924const GET_MARKDOWN_ARGS_FIELDS: &[&str] = &["file_id_or_url",
1925                                            "enable_ocr",
1926                                            "embed_images"];
1927impl GetMarkdownArgs {
1928    // no _opt deserializer
1929    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1930        mut map: V,
1931    ) -> Result<GetMarkdownArgs, V::Error> {
1932        let mut field_file_id_or_url = None;
1933        let mut field_enable_ocr = None;
1934        let mut field_embed_images = None;
1935        while let Some(key) = map.next_key::<&str>()? {
1936            match key {
1937                "file_id_or_url" => {
1938                    if field_file_id_or_url.is_some() {
1939                        return Err(::serde::de::Error::duplicate_field("file_id_or_url"));
1940                    }
1941                    field_file_id_or_url = Some(map.next_value()?);
1942                }
1943                "enable_ocr" => {
1944                    if field_enable_ocr.is_some() {
1945                        return Err(::serde::de::Error::duplicate_field("enable_ocr"));
1946                    }
1947                    field_enable_ocr = Some(map.next_value()?);
1948                }
1949                "embed_images" => {
1950                    if field_embed_images.is_some() {
1951                        return Err(::serde::de::Error::duplicate_field("embed_images"));
1952                    }
1953                    field_embed_images = Some(map.next_value()?);
1954                }
1955                _ => {
1956                    // unknown field allowed and ignored
1957                    map.next_value::<::serde_json::Value>()?;
1958                }
1959            }
1960        }
1961        let result = GetMarkdownArgs {
1962            file_id_or_url: field_file_id_or_url.and_then(Option::flatten),
1963            enable_ocr: field_enable_ocr.unwrap_or(false),
1964            embed_images: field_embed_images.unwrap_or(false),
1965        };
1966        Ok(result)
1967    }
1968
1969    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1970        &self,
1971        s: &mut S::SerializeStruct,
1972    ) -> Result<(), S::Error> {
1973        use serde::ser::SerializeStruct;
1974        if let Some(val) = &self.file_id_or_url {
1975            s.serialize_field("file_id_or_url", val)?;
1976        }
1977        if self.enable_ocr {
1978            s.serialize_field("enable_ocr", &self.enable_ocr)?;
1979        }
1980        if self.embed_images {
1981            s.serialize_field("embed_images", &self.embed_images)?;
1982        }
1983        Ok(())
1984    }
1985}
1986
1987impl<'de> ::serde::de::Deserialize<'de> for GetMarkdownArgs {
1988    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1989        // struct deserializer
1990        use serde::de::{MapAccess, Visitor};
1991        struct StructVisitor;
1992        impl<'de> Visitor<'de> for StructVisitor {
1993            type Value = GetMarkdownArgs;
1994            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1995                f.write_str("a GetMarkdownArgs struct")
1996            }
1997            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1998                GetMarkdownArgs::internal_deserialize(map)
1999            }
2000        }
2001        deserializer.deserialize_struct("GetMarkdownArgs", GET_MARKDOWN_ARGS_FIELDS, StructVisitor)
2002    }
2003}
2004
2005impl ::serde::ser::Serialize for GetMarkdownArgs {
2006    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2007        // struct serializer
2008        use serde::ser::SerializeStruct;
2009        let mut s = serializer.serialize_struct("GetMarkdownArgs", 3)?;
2010        self.internal_serialize::<S>(&mut s)?;
2011        s.end()
2012    }
2013}
2014
2015/// Result type for EventBus async check
2016#[derive(Debug, Clone, PartialEq, Eq)]
2017#[non_exhaustive] // variants may be added in the future
2018pub enum GetMarkdownAsyncCheckResult {
2019    InProgress,
2020    Complete(GetMarkdownResult),
2021    Failed(MarkdownConversionApiV2Error),
2022    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2023    /// typically indicates that this SDK version is out of date.
2024    Other,
2025}
2026
2027impl<'de> ::serde::de::Deserialize<'de> for GetMarkdownAsyncCheckResult {
2028    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2029        // union deserializer
2030        use serde::de::{self, MapAccess, Visitor};
2031        struct EnumVisitor;
2032        impl<'de> Visitor<'de> for EnumVisitor {
2033            type Value = GetMarkdownAsyncCheckResult;
2034            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2035                f.write_str("a GetMarkdownAsyncCheckResult structure")
2036            }
2037            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2038                let tag: &str = match map.next_key()? {
2039                    Some(".tag") => map.next_value()?,
2040                    _ => return Err(de::Error::missing_field(".tag"))
2041                };
2042                let value = match tag {
2043                    "in_progress" => GetMarkdownAsyncCheckResult::InProgress,
2044                    "complete" => GetMarkdownAsyncCheckResult::Complete(GetMarkdownResult::internal_deserialize(&mut map)?),
2045                    "failed" => {
2046                        match map.next_key()? {
2047                            Some("failed") => GetMarkdownAsyncCheckResult::Failed(map.next_value()?),
2048                            None => return Err(de::Error::missing_field("failed")),
2049                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2050                        }
2051                    }
2052                    _ => GetMarkdownAsyncCheckResult::Other,
2053                };
2054                crate::eat_json_fields(&mut map)?;
2055                Ok(value)
2056            }
2057        }
2058        const VARIANTS: &[&str] = &["in_progress",
2059                                    "complete",
2060                                    "failed",
2061                                    "other"];
2062        deserializer.deserialize_struct("GetMarkdownAsyncCheckResult", VARIANTS, EnumVisitor)
2063    }
2064}
2065
2066impl ::serde::ser::Serialize for GetMarkdownAsyncCheckResult {
2067    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2068        // union serializer
2069        use serde::ser::SerializeStruct;
2070        match self {
2071            GetMarkdownAsyncCheckResult::InProgress => {
2072                // unit
2073                let mut s = serializer.serialize_struct("GetMarkdownAsyncCheckResult", 1)?;
2074                s.serialize_field(".tag", "in_progress")?;
2075                s.end()
2076            }
2077            GetMarkdownAsyncCheckResult::Complete(x) => {
2078                // struct
2079                let mut s = serializer.serialize_struct("GetMarkdownAsyncCheckResult", 2)?;
2080                s.serialize_field(".tag", "complete")?;
2081                x.internal_serialize::<S>(&mut s)?;
2082                s.end()
2083            }
2084            GetMarkdownAsyncCheckResult::Failed(x) => {
2085                // union or polymporphic struct
2086                let mut s = serializer.serialize_struct("GetMarkdownAsyncCheckResult", 2)?;
2087                s.serialize_field(".tag", "failed")?;
2088                s.serialize_field("failed", x)?;
2089                s.end()
2090            }
2091            GetMarkdownAsyncCheckResult::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2092        }
2093    }
2094}
2095
2096#[derive(Debug, Clone, PartialEq, Eq, Default)]
2097#[non_exhaustive] // structs may have more fields added in the future.
2098pub struct GetMarkdownResult {
2099    /// The converted markdown content
2100    pub markdown: String,
2101}
2102
2103impl GetMarkdownResult {
2104    pub fn with_markdown(mut self, value: String) -> Self {
2105        self.markdown = value;
2106        self
2107    }
2108}
2109
2110const GET_MARKDOWN_RESULT_FIELDS: &[&str] = &["markdown"];
2111impl GetMarkdownResult {
2112    // no _opt deserializer
2113    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2114        mut map: V,
2115    ) -> Result<GetMarkdownResult, V::Error> {
2116        let mut field_markdown = None;
2117        while let Some(key) = map.next_key::<&str>()? {
2118            match key {
2119                "markdown" => {
2120                    if field_markdown.is_some() {
2121                        return Err(::serde::de::Error::duplicate_field("markdown"));
2122                    }
2123                    field_markdown = Some(map.next_value()?);
2124                }
2125                _ => {
2126                    // unknown field allowed and ignored
2127                    map.next_value::<::serde_json::Value>()?;
2128                }
2129            }
2130        }
2131        let result = GetMarkdownResult {
2132            markdown: field_markdown.unwrap_or_default(),
2133        };
2134        Ok(result)
2135    }
2136
2137    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2138        &self,
2139        s: &mut S::SerializeStruct,
2140    ) -> Result<(), S::Error> {
2141        use serde::ser::SerializeStruct;
2142        if !self.markdown.is_empty() {
2143            s.serialize_field("markdown", &self.markdown)?;
2144        }
2145        Ok(())
2146    }
2147}
2148
2149impl<'de> ::serde::de::Deserialize<'de> for GetMarkdownResult {
2150    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2151        // struct deserializer
2152        use serde::de::{MapAccess, Visitor};
2153        struct StructVisitor;
2154        impl<'de> Visitor<'de> for StructVisitor {
2155            type Value = GetMarkdownResult;
2156            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2157                f.write_str("a GetMarkdownResult struct")
2158            }
2159            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2160                GetMarkdownResult::internal_deserialize(map)
2161            }
2162        }
2163        deserializer.deserialize_struct("GetMarkdownResult", GET_MARKDOWN_RESULT_FIELDS, StructVisitor)
2164    }
2165}
2166
2167impl ::serde::ser::Serialize for GetMarkdownResult {
2168    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2169        // struct serializer
2170        use serde::ser::SerializeStruct;
2171        let mut s = serializer.serialize_struct("GetMarkdownResult", 1)?;
2172        self.internal_serialize::<S>(&mut s)?;
2173        s.end()
2174    }
2175}
2176
2177/// Arguments for the asynchronous `get_metadata_async` route. Exactly one of `file_id`, `path`, or
2178/// `url` must be supplied via `file_id_or_url` to identify the file whose metadata should be
2179/// extracted.
2180#[derive(Debug, Clone, PartialEq, Eq, Default)]
2181#[non_exhaustive] // structs may have more fields added in the future.
2182pub struct GetMetadataArgs {
2183    /// Identifier of the file to extract metadata from. Callers must set exactly one of the
2184    /// `FileIdOrUrl` variants. The kind of metadata returned is determined by the file type: image
2185    /// files return EXIF metadata, audio/video files return media metadata, PDFs return PDF
2186    /// metadata, and MS Office documents (docx, pptx, xlsx) return Office metadata. See the route
2187    /// description for the supported formats. Requests against unsupported formats return
2188    /// `unsupported_format_error`.
2189    pub file_id_or_url: Option<FileIdOrUrl>,
2190}
2191
2192impl GetMetadataArgs {
2193    pub fn with_file_id_or_url(mut self, value: FileIdOrUrl) -> Self {
2194        self.file_id_or_url = Some(value);
2195        self
2196    }
2197}
2198
2199const GET_METADATA_ARGS_FIELDS: &[&str] = &["file_id_or_url"];
2200impl GetMetadataArgs {
2201    // no _opt deserializer
2202    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2203        mut map: V,
2204    ) -> Result<GetMetadataArgs, V::Error> {
2205        let mut field_file_id_or_url = None;
2206        while let Some(key) = map.next_key::<&str>()? {
2207            match key {
2208                "file_id_or_url" => {
2209                    if field_file_id_or_url.is_some() {
2210                        return Err(::serde::de::Error::duplicate_field("file_id_or_url"));
2211                    }
2212                    field_file_id_or_url = Some(map.next_value()?);
2213                }
2214                _ => {
2215                    // unknown field allowed and ignored
2216                    map.next_value::<::serde_json::Value>()?;
2217                }
2218            }
2219        }
2220        let result = GetMetadataArgs {
2221            file_id_or_url: field_file_id_or_url.and_then(Option::flatten),
2222        };
2223        Ok(result)
2224    }
2225
2226    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2227        &self,
2228        s: &mut S::SerializeStruct,
2229    ) -> Result<(), S::Error> {
2230        use serde::ser::SerializeStruct;
2231        if let Some(val) = &self.file_id_or_url {
2232            s.serialize_field("file_id_or_url", val)?;
2233        }
2234        Ok(())
2235    }
2236}
2237
2238impl<'de> ::serde::de::Deserialize<'de> for GetMetadataArgs {
2239    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2240        // struct deserializer
2241        use serde::de::{MapAccess, Visitor};
2242        struct StructVisitor;
2243        impl<'de> Visitor<'de> for StructVisitor {
2244            type Value = GetMetadataArgs;
2245            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2246                f.write_str("a GetMetadataArgs struct")
2247            }
2248            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2249                GetMetadataArgs::internal_deserialize(map)
2250            }
2251        }
2252        deserializer.deserialize_struct("GetMetadataArgs", GET_METADATA_ARGS_FIELDS, StructVisitor)
2253    }
2254}
2255
2256impl ::serde::ser::Serialize for GetMetadataArgs {
2257    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2258        // struct serializer
2259        use serde::ser::SerializeStruct;
2260        let mut s = serializer.serialize_struct("GetMetadataArgs", 1)?;
2261        self.internal_serialize::<S>(&mut s)?;
2262        s.end()
2263    }
2264}
2265
2266/// Result type for EventBus async check - must end in "CheckResult"
2267#[derive(Debug, Clone, PartialEq)]
2268#[non_exhaustive] // variants may be added in the future
2269pub enum GetMetadataAsyncCheckResult {
2270    InProgress,
2271    Complete(GetMetadataResult),
2272    Failed(MetadataExtractionApiV2Error),
2273    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2274    /// typically indicates that this SDK version is out of date.
2275    Other,
2276}
2277
2278impl<'de> ::serde::de::Deserialize<'de> for GetMetadataAsyncCheckResult {
2279    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2280        // union deserializer
2281        use serde::de::{self, MapAccess, Visitor};
2282        struct EnumVisitor;
2283        impl<'de> Visitor<'de> for EnumVisitor {
2284            type Value = GetMetadataAsyncCheckResult;
2285            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2286                f.write_str("a GetMetadataAsyncCheckResult structure")
2287            }
2288            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2289                let tag: &str = match map.next_key()? {
2290                    Some(".tag") => map.next_value()?,
2291                    _ => return Err(de::Error::missing_field(".tag"))
2292                };
2293                let value = match tag {
2294                    "in_progress" => GetMetadataAsyncCheckResult::InProgress,
2295                    "complete" => GetMetadataAsyncCheckResult::Complete(GetMetadataResult::internal_deserialize(&mut map)?),
2296                    "failed" => {
2297                        match map.next_key()? {
2298                            Some("failed") => GetMetadataAsyncCheckResult::Failed(map.next_value()?),
2299                            None => return Err(de::Error::missing_field("failed")),
2300                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2301                        }
2302                    }
2303                    _ => GetMetadataAsyncCheckResult::Other,
2304                };
2305                crate::eat_json_fields(&mut map)?;
2306                Ok(value)
2307            }
2308        }
2309        const VARIANTS: &[&str] = &["in_progress",
2310                                    "complete",
2311                                    "failed",
2312                                    "other"];
2313        deserializer.deserialize_struct("GetMetadataAsyncCheckResult", VARIANTS, EnumVisitor)
2314    }
2315}
2316
2317impl ::serde::ser::Serialize for GetMetadataAsyncCheckResult {
2318    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2319        // union serializer
2320        use serde::ser::SerializeStruct;
2321        match self {
2322            GetMetadataAsyncCheckResult::InProgress => {
2323                // unit
2324                let mut s = serializer.serialize_struct("GetMetadataAsyncCheckResult", 1)?;
2325                s.serialize_field(".tag", "in_progress")?;
2326                s.end()
2327            }
2328            GetMetadataAsyncCheckResult::Complete(x) => {
2329                // struct
2330                let mut s = serializer.serialize_struct("GetMetadataAsyncCheckResult", 3)?;
2331                s.serialize_field(".tag", "complete")?;
2332                x.internal_serialize::<S>(&mut s)?;
2333                s.end()
2334            }
2335            GetMetadataAsyncCheckResult::Failed(x) => {
2336                // union or polymporphic struct
2337                let mut s = serializer.serialize_struct("GetMetadataAsyncCheckResult", 2)?;
2338                s.serialize_field(".tag", "failed")?;
2339                s.serialize_field("failed", x)?;
2340                s.end()
2341            }
2342            GetMetadataAsyncCheckResult::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2343        }
2344    }
2345}
2346
2347#[derive(Debug, Clone, PartialEq)]
2348#[non_exhaustive] // structs may have more fields added in the future.
2349pub struct GetMetadataResult {
2350    /// The kind of metadata that was extracted for the requested file. Callers should read the
2351    /// matching field of the `metadata` oneof.
2352    pub metadata_type: MetadataType,
2353    pub metadata: Option<MetadataUnion>,
2354}
2355
2356impl Default for GetMetadataResult {
2357    fn default() -> Self {
2358        GetMetadataResult {
2359            metadata_type: MetadataType::MetadataTypeUnknown,
2360            metadata: None,
2361        }
2362    }
2363}
2364
2365impl GetMetadataResult {
2366    pub fn with_metadata_type(mut self, value: MetadataType) -> Self {
2367        self.metadata_type = value;
2368        self
2369    }
2370
2371    pub fn with_metadata(mut self, value: MetadataUnion) -> Self {
2372        self.metadata = Some(value);
2373        self
2374    }
2375}
2376
2377const GET_METADATA_RESULT_FIELDS: &[&str] = &["metadata_type",
2378                                              "metadata"];
2379impl GetMetadataResult {
2380    // no _opt deserializer
2381    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2382        mut map: V,
2383    ) -> Result<GetMetadataResult, V::Error> {
2384        let mut field_metadata_type = None;
2385        let mut field_metadata = None;
2386        while let Some(key) = map.next_key::<&str>()? {
2387            match key {
2388                "metadata_type" => {
2389                    if field_metadata_type.is_some() {
2390                        return Err(::serde::de::Error::duplicate_field("metadata_type"));
2391                    }
2392                    field_metadata_type = Some(map.next_value()?);
2393                }
2394                "metadata" => {
2395                    if field_metadata.is_some() {
2396                        return Err(::serde::de::Error::duplicate_field("metadata"));
2397                    }
2398                    field_metadata = Some(map.next_value()?);
2399                }
2400                _ => {
2401                    // unknown field allowed and ignored
2402                    map.next_value::<::serde_json::Value>()?;
2403                }
2404            }
2405        }
2406        let result = GetMetadataResult {
2407            metadata_type: field_metadata_type.unwrap_or(MetadataType::MetadataTypeUnknown),
2408            metadata: field_metadata.and_then(Option::flatten),
2409        };
2410        Ok(result)
2411    }
2412
2413    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2414        &self,
2415        s: &mut S::SerializeStruct,
2416    ) -> Result<(), S::Error> {
2417        use serde::ser::SerializeStruct;
2418        if self.metadata_type != MetadataType::MetadataTypeUnknown {
2419            s.serialize_field("metadata_type", &self.metadata_type)?;
2420        }
2421        if let Some(val) = &self.metadata {
2422            s.serialize_field("metadata", val)?;
2423        }
2424        Ok(())
2425    }
2426}
2427
2428impl<'de> ::serde::de::Deserialize<'de> for GetMetadataResult {
2429    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2430        // struct deserializer
2431        use serde::de::{MapAccess, Visitor};
2432        struct StructVisitor;
2433        impl<'de> Visitor<'de> for StructVisitor {
2434            type Value = GetMetadataResult;
2435            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2436                f.write_str("a GetMetadataResult struct")
2437            }
2438            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2439                GetMetadataResult::internal_deserialize(map)
2440            }
2441        }
2442        deserializer.deserialize_struct("GetMetadataResult", GET_METADATA_RESULT_FIELDS, StructVisitor)
2443    }
2444}
2445
2446impl ::serde::ser::Serialize for GetMetadataResult {
2447    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2448        // struct serializer
2449        use serde::ser::SerializeStruct;
2450        let mut s = serializer.serialize_struct("GetMetadataResult", 2)?;
2451        self.internal_serialize::<S>(&mut s)?;
2452        s.end()
2453    }
2454}
2455
2456/// Arguments for the asynchronous `get_transcript_async` route. Exactly one of `file_id`, `path`,
2457/// or `url` must be supplied via `file_id_or_url` to identify the audio or video asset to
2458/// transcribe.
2459#[derive(Debug, Clone, PartialEq, Eq)]
2460#[non_exhaustive] // structs may have more fields added in the future.
2461pub struct GetTranscriptArgs {
2462    /// Identifier of the media asset to transcribe. Callers must set exactly one of the
2463    /// `FileIdOrUrl` variants. The referenced asset must be an audio or video file in a supported
2464    /// format (see the route description for the list); requests against files with no audio track
2465    /// return a `no_audio_error`.
2466    pub file_id_or_url: Option<FileIdOrUrl>,
2467    /// Granularity of the time offsets returned for each transcript segment. Defaults to `SENTENCE`
2468    /// when the field is omitted. - SENTENCE: one segment per spoken sentence (recommended). -
2469    /// WORD: one segment per word, useful for fine-grained alignment such as captioning or
2470    /// highlight-as-you-listen experiences.
2471    pub timestamp_level: TimestampLevel,
2472    /// Comma-delimited list of non-lexical filler words to preserve in the transcript output, e.g.
2473    /// `"uh, ah, uhm"`. By default these fillers are stripped. Unrecognized tokens are ignored.
2474    /// Leave empty to use the default filtering behavior.
2475    pub included_special_words: String,
2476    /// Optional ISO 639-1 two-letter language code hinting the spoken language of the source audio
2477    /// (e.g. "en", "ja"). When empty, the service auto-detects the language; supplying a hint
2478    /// improves accuracy and latency for short or ambiguous clips. Unsupported languages fall back
2479    /// to auto-detection.
2480    pub audio_language: String,
2481}
2482
2483impl Default for GetTranscriptArgs {
2484    fn default() -> Self {
2485        GetTranscriptArgs {
2486            file_id_or_url: None,
2487            timestamp_level: TimestampLevel::Sentence,
2488            included_special_words: String::new(),
2489            audio_language: String::new(),
2490        }
2491    }
2492}
2493
2494impl GetTranscriptArgs {
2495    pub fn with_file_id_or_url(mut self, value: FileIdOrUrl) -> Self {
2496        self.file_id_or_url = Some(value);
2497        self
2498    }
2499
2500    pub fn with_timestamp_level(mut self, value: TimestampLevel) -> Self {
2501        self.timestamp_level = value;
2502        self
2503    }
2504
2505    pub fn with_included_special_words(mut self, value: String) -> Self {
2506        self.included_special_words = value;
2507        self
2508    }
2509
2510    pub fn with_audio_language(mut self, value: String) -> Self {
2511        self.audio_language = value;
2512        self
2513    }
2514}
2515
2516const GET_TRANSCRIPT_ARGS_FIELDS: &[&str] = &["file_id_or_url",
2517                                              "timestamp_level",
2518                                              "included_special_words",
2519                                              "audio_language"];
2520impl GetTranscriptArgs {
2521    // no _opt deserializer
2522    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2523        mut map: V,
2524    ) -> Result<GetTranscriptArgs, V::Error> {
2525        let mut field_file_id_or_url = None;
2526        let mut field_timestamp_level = None;
2527        let mut field_included_special_words = None;
2528        let mut field_audio_language = None;
2529        while let Some(key) = map.next_key::<&str>()? {
2530            match key {
2531                "file_id_or_url" => {
2532                    if field_file_id_or_url.is_some() {
2533                        return Err(::serde::de::Error::duplicate_field("file_id_or_url"));
2534                    }
2535                    field_file_id_or_url = Some(map.next_value()?);
2536                }
2537                "timestamp_level" => {
2538                    if field_timestamp_level.is_some() {
2539                        return Err(::serde::de::Error::duplicate_field("timestamp_level"));
2540                    }
2541                    field_timestamp_level = Some(map.next_value()?);
2542                }
2543                "included_special_words" => {
2544                    if field_included_special_words.is_some() {
2545                        return Err(::serde::de::Error::duplicate_field("included_special_words"));
2546                    }
2547                    field_included_special_words = Some(map.next_value()?);
2548                }
2549                "audio_language" => {
2550                    if field_audio_language.is_some() {
2551                        return Err(::serde::de::Error::duplicate_field("audio_language"));
2552                    }
2553                    field_audio_language = Some(map.next_value()?);
2554                }
2555                _ => {
2556                    // unknown field allowed and ignored
2557                    map.next_value::<::serde_json::Value>()?;
2558                }
2559            }
2560        }
2561        let result = GetTranscriptArgs {
2562            file_id_or_url: field_file_id_or_url.and_then(Option::flatten),
2563            timestamp_level: field_timestamp_level.unwrap_or(TimestampLevel::Sentence),
2564            included_special_words: field_included_special_words.unwrap_or_default(),
2565            audio_language: field_audio_language.unwrap_or_default(),
2566        };
2567        Ok(result)
2568    }
2569
2570    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2571        &self,
2572        s: &mut S::SerializeStruct,
2573    ) -> Result<(), S::Error> {
2574        use serde::ser::SerializeStruct;
2575        if let Some(val) = &self.file_id_or_url {
2576            s.serialize_field("file_id_or_url", val)?;
2577        }
2578        if self.timestamp_level != TimestampLevel::Sentence {
2579            s.serialize_field("timestamp_level", &self.timestamp_level)?;
2580        }
2581        if !self.included_special_words.is_empty() {
2582            s.serialize_field("included_special_words", &self.included_special_words)?;
2583        }
2584        if !self.audio_language.is_empty() {
2585            s.serialize_field("audio_language", &self.audio_language)?;
2586        }
2587        Ok(())
2588    }
2589}
2590
2591impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptArgs {
2592    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2593        // struct deserializer
2594        use serde::de::{MapAccess, Visitor};
2595        struct StructVisitor;
2596        impl<'de> Visitor<'de> for StructVisitor {
2597            type Value = GetTranscriptArgs;
2598            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2599                f.write_str("a GetTranscriptArgs struct")
2600            }
2601            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2602                GetTranscriptArgs::internal_deserialize(map)
2603            }
2604        }
2605        deserializer.deserialize_struct("GetTranscriptArgs", GET_TRANSCRIPT_ARGS_FIELDS, StructVisitor)
2606    }
2607}
2608
2609impl ::serde::ser::Serialize for GetTranscriptArgs {
2610    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2611        // struct serializer
2612        use serde::ser::SerializeStruct;
2613        let mut s = serializer.serialize_struct("GetTranscriptArgs", 4)?;
2614        self.internal_serialize::<S>(&mut s)?;
2615        s.end()
2616    }
2617}
2618
2619/// Result type for EventBus async check - must end in "CheckResult"
2620#[derive(Debug, Clone, PartialEq)]
2621#[non_exhaustive] // variants may be added in the future
2622pub enum GetTranscriptAsyncCheckResult {
2623    InProgress,
2624    Complete(GetTranscriptResult),
2625    Failed(ContentApiV2Error),
2626    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2627    /// typically indicates that this SDK version is out of date.
2628    Other,
2629}
2630
2631impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptAsyncCheckResult {
2632    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2633        // union deserializer
2634        use serde::de::{self, MapAccess, Visitor};
2635        struct EnumVisitor;
2636        impl<'de> Visitor<'de> for EnumVisitor {
2637            type Value = GetTranscriptAsyncCheckResult;
2638            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2639                f.write_str("a GetTranscriptAsyncCheckResult structure")
2640            }
2641            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2642                let tag: &str = match map.next_key()? {
2643                    Some(".tag") => map.next_value()?,
2644                    _ => return Err(de::Error::missing_field(".tag"))
2645                };
2646                let value = match tag {
2647                    "in_progress" => GetTranscriptAsyncCheckResult::InProgress,
2648                    "complete" => GetTranscriptAsyncCheckResult::Complete(GetTranscriptResult::internal_deserialize(&mut map)?),
2649                    "failed" => {
2650                        match map.next_key()? {
2651                            Some("failed") => GetTranscriptAsyncCheckResult::Failed(map.next_value()?),
2652                            None => return Err(de::Error::missing_field("failed")),
2653                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2654                        }
2655                    }
2656                    _ => GetTranscriptAsyncCheckResult::Other,
2657                };
2658                crate::eat_json_fields(&mut map)?;
2659                Ok(value)
2660            }
2661        }
2662        const VARIANTS: &[&str] = &["in_progress",
2663                                    "complete",
2664                                    "failed",
2665                                    "other"];
2666        deserializer.deserialize_struct("GetTranscriptAsyncCheckResult", VARIANTS, EnumVisitor)
2667    }
2668}
2669
2670impl ::serde::ser::Serialize for GetTranscriptAsyncCheckResult {
2671    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2672        // union serializer
2673        use serde::ser::SerializeStruct;
2674        match self {
2675            GetTranscriptAsyncCheckResult::InProgress => {
2676                // unit
2677                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 1)?;
2678                s.serialize_field(".tag", "in_progress")?;
2679                s.end()
2680            }
2681            GetTranscriptAsyncCheckResult::Complete(x) => {
2682                // struct
2683                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 2)?;
2684                s.serialize_field(".tag", "complete")?;
2685                x.internal_serialize::<S>(&mut s)?;
2686                s.end()
2687            }
2688            GetTranscriptAsyncCheckResult::Failed(x) => {
2689                // union or polymporphic struct
2690                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 2)?;
2691                s.serialize_field(".tag", "failed")?;
2692                s.serialize_field("failed", x)?;
2693                s.end()
2694            }
2695            GetTranscriptAsyncCheckResult::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2696        }
2697    }
2698}
2699
2700#[derive(Debug, Clone, PartialEq, Default)]
2701#[non_exhaustive] // structs may have more fields added in the future.
2702pub struct GetTranscriptResult {
2703    /// The structured transcript produced for the requested media asset, with per-segment text,
2704    /// start/end offsets (in seconds from the beginning of the media), and the detected or
2705    /// caller-supplied locale.
2706    pub structured_transcript: Option<ApiStructuredTranscript>,
2707}
2708
2709impl GetTranscriptResult {
2710    pub fn with_structured_transcript(mut self, value: ApiStructuredTranscript) -> Self {
2711        self.structured_transcript = Some(value);
2712        self
2713    }
2714}
2715
2716const GET_TRANSCRIPT_RESULT_FIELDS: &[&str] = &["structured_transcript"];
2717impl GetTranscriptResult {
2718    // no _opt deserializer
2719    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2720        mut map: V,
2721    ) -> Result<GetTranscriptResult, V::Error> {
2722        let mut field_structured_transcript = None;
2723        while let Some(key) = map.next_key::<&str>()? {
2724            match key {
2725                "structured_transcript" => {
2726                    if field_structured_transcript.is_some() {
2727                        return Err(::serde::de::Error::duplicate_field("structured_transcript"));
2728                    }
2729                    field_structured_transcript = Some(map.next_value()?);
2730                }
2731                _ => {
2732                    // unknown field allowed and ignored
2733                    map.next_value::<::serde_json::Value>()?;
2734                }
2735            }
2736        }
2737        let result = GetTranscriptResult {
2738            structured_transcript: field_structured_transcript.and_then(Option::flatten),
2739        };
2740        Ok(result)
2741    }
2742
2743    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2744        &self,
2745        s: &mut S::SerializeStruct,
2746    ) -> Result<(), S::Error> {
2747        use serde::ser::SerializeStruct;
2748        if let Some(val) = &self.structured_transcript {
2749            s.serialize_field("structured_transcript", val)?;
2750        }
2751        Ok(())
2752    }
2753}
2754
2755impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptResult {
2756    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2757        // struct deserializer
2758        use serde::de::{MapAccess, Visitor};
2759        struct StructVisitor;
2760        impl<'de> Visitor<'de> for StructVisitor {
2761            type Value = GetTranscriptResult;
2762            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2763                f.write_str("a GetTranscriptResult struct")
2764            }
2765            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2766                GetTranscriptResult::internal_deserialize(map)
2767            }
2768        }
2769        deserializer.deserialize_struct("GetTranscriptResult", GET_TRANSCRIPT_RESULT_FIELDS, StructVisitor)
2770    }
2771}
2772
2773impl ::serde::ser::Serialize for GetTranscriptResult {
2774    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2775        // struct serializer
2776        use serde::ser::SerializeStruct;
2777        let mut s = serializer.serialize_struct("GetTranscriptResult", 1)?;
2778        self.internal_serialize::<S>(&mut s)?;
2779        s.end()
2780    }
2781}
2782
2783/// Reason a markdown conversion job failed. Returned in the `failed` variant of
2784/// `GetMarkdownAsyncCheckResult`. This is a semantic error union: the HTTP status of the poll
2785/// request itself is unaffected (a poll that surfaces a failed job is still a normal successful
2786/// poll response). Callers should branch on the variant.
2787#[derive(Debug, Clone, PartialEq, Eq)]
2788#[non_exhaustive] // variants may be added in the future
2789pub enum MarkdownConversionApiV2Error {
2790    /// An unexpected, typically transient, server-side failure. The string is a human-readable
2791    /// message; retrying with backoff may succeed.
2792    ServerError(String),
2793    /// The request could not be processed as supplied (a problem with the caller's input). The
2794    /// string is a human-readable message; retrying the same request will not help.
2795    UserError(String),
2796    UnsupportedFormatError,
2797    LinkDownloadDisabledError,
2798    SharedLinkPasswordProtected,
2799    LimitExceededError,
2800    ConversionFailureError,
2801    /// The referenced file does not exist or is not accessible.
2802    NotFoundError,
2803    /// The target is a folder, not a file.
2804    IsAFolderError,
2805    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2806    /// typically indicates that this SDK version is out of date.
2807    Other,
2808}
2809
2810impl<'de> ::serde::de::Deserialize<'de> for MarkdownConversionApiV2Error {
2811    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2812        // union deserializer
2813        use serde::de::{self, MapAccess, Visitor};
2814        struct EnumVisitor;
2815        impl<'de> Visitor<'de> for EnumVisitor {
2816            type Value = MarkdownConversionApiV2Error;
2817            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2818                f.write_str("a MarkdownConversionApiV2Error structure")
2819            }
2820            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2821                let tag: &str = match map.next_key()? {
2822                    Some(".tag") => map.next_value()?,
2823                    _ => return Err(de::Error::missing_field(".tag"))
2824                };
2825                let value = match tag {
2826                    "server_error" => {
2827                        match map.next_key()? {
2828                            Some("server_error") => MarkdownConversionApiV2Error::ServerError(map.next_value()?),
2829                            None => return Err(de::Error::missing_field("server_error")),
2830                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2831                        }
2832                    }
2833                    "user_error" => {
2834                        match map.next_key()? {
2835                            Some("user_error") => MarkdownConversionApiV2Error::UserError(map.next_value()?),
2836                            None => return Err(de::Error::missing_field("user_error")),
2837                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2838                        }
2839                    }
2840                    "unsupported_format_error" => MarkdownConversionApiV2Error::UnsupportedFormatError,
2841                    "link_download_disabled_error" => MarkdownConversionApiV2Error::LinkDownloadDisabledError,
2842                    "shared_link_password_protected" => MarkdownConversionApiV2Error::SharedLinkPasswordProtected,
2843                    "limit_exceeded_error" => MarkdownConversionApiV2Error::LimitExceededError,
2844                    "conversion_failure_error" => MarkdownConversionApiV2Error::ConversionFailureError,
2845                    "not_found_error" => MarkdownConversionApiV2Error::NotFoundError,
2846                    "is_a_folder_error" => MarkdownConversionApiV2Error::IsAFolderError,
2847                    _ => MarkdownConversionApiV2Error::Other,
2848                };
2849                crate::eat_json_fields(&mut map)?;
2850                Ok(value)
2851            }
2852        }
2853        const VARIANTS: &[&str] = &["server_error",
2854                                    "user_error",
2855                                    "unsupported_format_error",
2856                                    "link_download_disabled_error",
2857                                    "shared_link_password_protected",
2858                                    "limit_exceeded_error",
2859                                    "conversion_failure_error",
2860                                    "not_found_error",
2861                                    "is_a_folder_error",
2862                                    "other"];
2863        deserializer.deserialize_struct("MarkdownConversionApiV2Error", VARIANTS, EnumVisitor)
2864    }
2865}
2866
2867impl ::serde::ser::Serialize for MarkdownConversionApiV2Error {
2868    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2869        // union serializer
2870        use serde::ser::SerializeStruct;
2871        match self {
2872            MarkdownConversionApiV2Error::ServerError(x) => {
2873                // primitive
2874                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 2)?;
2875                s.serialize_field(".tag", "server_error")?;
2876                s.serialize_field("server_error", x)?;
2877                s.end()
2878            }
2879            MarkdownConversionApiV2Error::UserError(x) => {
2880                // primitive
2881                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 2)?;
2882                s.serialize_field(".tag", "user_error")?;
2883                s.serialize_field("user_error", x)?;
2884                s.end()
2885            }
2886            MarkdownConversionApiV2Error::UnsupportedFormatError => {
2887                // unit
2888                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
2889                s.serialize_field(".tag", "unsupported_format_error")?;
2890                s.end()
2891            }
2892            MarkdownConversionApiV2Error::LinkDownloadDisabledError => {
2893                // unit
2894                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
2895                s.serialize_field(".tag", "link_download_disabled_error")?;
2896                s.end()
2897            }
2898            MarkdownConversionApiV2Error::SharedLinkPasswordProtected => {
2899                // unit
2900                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
2901                s.serialize_field(".tag", "shared_link_password_protected")?;
2902                s.end()
2903            }
2904            MarkdownConversionApiV2Error::LimitExceededError => {
2905                // unit
2906                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
2907                s.serialize_field(".tag", "limit_exceeded_error")?;
2908                s.end()
2909            }
2910            MarkdownConversionApiV2Error::ConversionFailureError => {
2911                // unit
2912                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
2913                s.serialize_field(".tag", "conversion_failure_error")?;
2914                s.end()
2915            }
2916            MarkdownConversionApiV2Error::NotFoundError => {
2917                // unit
2918                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
2919                s.serialize_field(".tag", "not_found_error")?;
2920                s.end()
2921            }
2922            MarkdownConversionApiV2Error::IsAFolderError => {
2923                // unit
2924                let mut s = serializer.serialize_struct("MarkdownConversionApiV2Error", 1)?;
2925                s.serialize_field(".tag", "is_a_folder_error")?;
2926                s.end()
2927            }
2928            MarkdownConversionApiV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2929        }
2930    }
2931}
2932
2933impl ::std::error::Error for MarkdownConversionApiV2Error {
2934}
2935
2936impl ::std::fmt::Display for MarkdownConversionApiV2Error {
2937    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2938        match self {
2939            MarkdownConversionApiV2Error::ServerError(inner) => write!(f, "An unexpected, typically transient, server-side failure. The string is a human-readable message; retrying with backoff may succeed: {:?}", inner),
2940            MarkdownConversionApiV2Error::UserError(inner) => write!(f, "The request could not be processed as supplied (a problem with the caller's input). The string is a human-readable message; retrying the same request will not help: {:?}", inner),
2941            MarkdownConversionApiV2Error::NotFoundError => f.write_str("The referenced file does not exist or is not accessible."),
2942            MarkdownConversionApiV2Error::IsAFolderError => f.write_str("The target is a folder, not a file."),
2943            _ => write!(f, "{:?}", *self),
2944        }
2945    }
2946}
2947
2948#[derive(Debug, Clone, PartialEq, Eq, Default)]
2949#[non_exhaustive] // structs may have more fields added in the future.
2950pub struct MediaDurationError {
2951    pub limit: i32,
2952}
2953
2954impl MediaDurationError {
2955    pub fn with_limit(mut self, value: i32) -> Self {
2956        self.limit = value;
2957        self
2958    }
2959}
2960
2961const MEDIA_DURATION_ERROR_FIELDS: &[&str] = &["limit"];
2962impl MediaDurationError {
2963    // no _opt deserializer
2964    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2965        mut map: V,
2966    ) -> Result<MediaDurationError, V::Error> {
2967        let mut field_limit = None;
2968        while let Some(key) = map.next_key::<&str>()? {
2969            match key {
2970                "limit" => {
2971                    if field_limit.is_some() {
2972                        return Err(::serde::de::Error::duplicate_field("limit"));
2973                    }
2974                    field_limit = Some(map.next_value()?);
2975                }
2976                _ => {
2977                    // unknown field allowed and ignored
2978                    map.next_value::<::serde_json::Value>()?;
2979                }
2980            }
2981        }
2982        let result = MediaDurationError {
2983            limit: field_limit.unwrap_or(0),
2984        };
2985        Ok(result)
2986    }
2987
2988    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2989        &self,
2990        s: &mut S::SerializeStruct,
2991    ) -> Result<(), S::Error> {
2992        use serde::ser::SerializeStruct;
2993        if self.limit != 0 {
2994            s.serialize_field("limit", &self.limit)?;
2995        }
2996        Ok(())
2997    }
2998}
2999
3000impl<'de> ::serde::de::Deserialize<'de> for MediaDurationError {
3001    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3002        // struct deserializer
3003        use serde::de::{MapAccess, Visitor};
3004        struct StructVisitor;
3005        impl<'de> Visitor<'de> for StructVisitor {
3006            type Value = MediaDurationError;
3007            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3008                f.write_str("a MediaDurationError struct")
3009            }
3010            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3011                MediaDurationError::internal_deserialize(map)
3012            }
3013        }
3014        deserializer.deserialize_struct("MediaDurationError", MEDIA_DURATION_ERROR_FIELDS, StructVisitor)
3015    }
3016}
3017
3018impl ::serde::ser::Serialize for MediaDurationError {
3019    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3020        // struct serializer
3021        use serde::ser::SerializeStruct;
3022        let mut s = serializer.serialize_struct("MediaDurationError", 1)?;
3023        self.internal_serialize::<S>(&mut s)?;
3024        s.end()
3025    }
3026}
3027
3028/// Reason a metadata extraction job failed. Returned in the `failed` variant of
3029/// `GetMetadataAsyncCheckResult`. This is a semantic error union: the HTTP status of the poll
3030/// request itself is unaffected (a poll that surfaces a failed job is still a normal successful
3031/// poll response). Callers should branch on the variant.
3032#[derive(Debug, Clone, PartialEq, Eq)]
3033#[non_exhaustive] // variants may be added in the future
3034pub enum MetadataExtractionApiV2Error {
3035    /// An unexpected, typically transient, server-side failure. The string is a human-readable
3036    /// message; retrying with backoff may succeed.
3037    ServerError(String),
3038    /// The request could not be processed as supplied (a problem with the caller's input). The
3039    /// string is a human-readable message; retrying the same request will not help.
3040    UserError(String),
3041    UnsupportedFormatError,
3042    LinkDownloadDisabledError,
3043    SharedLinkPasswordProtected,
3044    LimitExceededError,
3045    ConversionFailureError,
3046    /// The referenced file does not exist or is not accessible.
3047    NotFoundError,
3048    /// The target is a folder, not a file.
3049    IsAFolderError,
3050    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3051    /// typically indicates that this SDK version is out of date.
3052    Other,
3053}
3054
3055impl<'de> ::serde::de::Deserialize<'de> for MetadataExtractionApiV2Error {
3056    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3057        // union deserializer
3058        use serde::de::{self, MapAccess, Visitor};
3059        struct EnumVisitor;
3060        impl<'de> Visitor<'de> for EnumVisitor {
3061            type Value = MetadataExtractionApiV2Error;
3062            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3063                f.write_str("a MetadataExtractionApiV2Error structure")
3064            }
3065            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3066                let tag: &str = match map.next_key()? {
3067                    Some(".tag") => map.next_value()?,
3068                    _ => return Err(de::Error::missing_field(".tag"))
3069                };
3070                let value = match tag {
3071                    "server_error" => {
3072                        match map.next_key()? {
3073                            Some("server_error") => MetadataExtractionApiV2Error::ServerError(map.next_value()?),
3074                            None => return Err(de::Error::missing_field("server_error")),
3075                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3076                        }
3077                    }
3078                    "user_error" => {
3079                        match map.next_key()? {
3080                            Some("user_error") => MetadataExtractionApiV2Error::UserError(map.next_value()?),
3081                            None => return Err(de::Error::missing_field("user_error")),
3082                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3083                        }
3084                    }
3085                    "unsupported_format_error" => MetadataExtractionApiV2Error::UnsupportedFormatError,
3086                    "link_download_disabled_error" => MetadataExtractionApiV2Error::LinkDownloadDisabledError,
3087                    "shared_link_password_protected" => MetadataExtractionApiV2Error::SharedLinkPasswordProtected,
3088                    "limit_exceeded_error" => MetadataExtractionApiV2Error::LimitExceededError,
3089                    "conversion_failure_error" => MetadataExtractionApiV2Error::ConversionFailureError,
3090                    "not_found_error" => MetadataExtractionApiV2Error::NotFoundError,
3091                    "is_a_folder_error" => MetadataExtractionApiV2Error::IsAFolderError,
3092                    _ => MetadataExtractionApiV2Error::Other,
3093                };
3094                crate::eat_json_fields(&mut map)?;
3095                Ok(value)
3096            }
3097        }
3098        const VARIANTS: &[&str] = &["server_error",
3099                                    "user_error",
3100                                    "unsupported_format_error",
3101                                    "link_download_disabled_error",
3102                                    "shared_link_password_protected",
3103                                    "limit_exceeded_error",
3104                                    "conversion_failure_error",
3105                                    "not_found_error",
3106                                    "is_a_folder_error",
3107                                    "other"];
3108        deserializer.deserialize_struct("MetadataExtractionApiV2Error", VARIANTS, EnumVisitor)
3109    }
3110}
3111
3112impl ::serde::ser::Serialize for MetadataExtractionApiV2Error {
3113    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3114        // union serializer
3115        use serde::ser::SerializeStruct;
3116        match self {
3117            MetadataExtractionApiV2Error::ServerError(x) => {
3118                // primitive
3119                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 2)?;
3120                s.serialize_field(".tag", "server_error")?;
3121                s.serialize_field("server_error", x)?;
3122                s.end()
3123            }
3124            MetadataExtractionApiV2Error::UserError(x) => {
3125                // primitive
3126                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 2)?;
3127                s.serialize_field(".tag", "user_error")?;
3128                s.serialize_field("user_error", x)?;
3129                s.end()
3130            }
3131            MetadataExtractionApiV2Error::UnsupportedFormatError => {
3132                // unit
3133                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3134                s.serialize_field(".tag", "unsupported_format_error")?;
3135                s.end()
3136            }
3137            MetadataExtractionApiV2Error::LinkDownloadDisabledError => {
3138                // unit
3139                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3140                s.serialize_field(".tag", "link_download_disabled_error")?;
3141                s.end()
3142            }
3143            MetadataExtractionApiV2Error::SharedLinkPasswordProtected => {
3144                // unit
3145                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3146                s.serialize_field(".tag", "shared_link_password_protected")?;
3147                s.end()
3148            }
3149            MetadataExtractionApiV2Error::LimitExceededError => {
3150                // unit
3151                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3152                s.serialize_field(".tag", "limit_exceeded_error")?;
3153                s.end()
3154            }
3155            MetadataExtractionApiV2Error::ConversionFailureError => {
3156                // unit
3157                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3158                s.serialize_field(".tag", "conversion_failure_error")?;
3159                s.end()
3160            }
3161            MetadataExtractionApiV2Error::NotFoundError => {
3162                // unit
3163                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3164                s.serialize_field(".tag", "not_found_error")?;
3165                s.end()
3166            }
3167            MetadataExtractionApiV2Error::IsAFolderError => {
3168                // unit
3169                let mut s = serializer.serialize_struct("MetadataExtractionApiV2Error", 1)?;
3170                s.serialize_field(".tag", "is_a_folder_error")?;
3171                s.end()
3172            }
3173            MetadataExtractionApiV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3174        }
3175    }
3176}
3177
3178impl ::std::error::Error for MetadataExtractionApiV2Error {
3179}
3180
3181impl ::std::fmt::Display for MetadataExtractionApiV2Error {
3182    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3183        match self {
3184            MetadataExtractionApiV2Error::ServerError(inner) => write!(f, "An unexpected, typically transient, server-side failure. The string is a human-readable message; retrying with backoff may succeed: {:?}", inner),
3185            MetadataExtractionApiV2Error::UserError(inner) => write!(f, "The request could not be processed as supplied (a problem with the caller's input). The string is a human-readable message; retrying the same request will not help: {:?}", inner),
3186            MetadataExtractionApiV2Error::NotFoundError => f.write_str("The referenced file does not exist or is not accessible."),
3187            MetadataExtractionApiV2Error::IsAFolderError => f.write_str("The target is a folder, not a file."),
3188            _ => write!(f, "{:?}", *self),
3189        }
3190    }
3191}
3192
3193/// Which metadata variant is populated in a `GetMetadataResult`, derived from the file type.
3194#[derive(Debug, Clone, PartialEq, Eq)]
3195#[non_exhaustive] // variants may be added in the future
3196pub enum MetadataType {
3197    MetadataTypeUnknown,
3198    MetadataTypeExif,
3199    MetadataTypeMedia,
3200    MetadataTypePdf,
3201    MetadataTypeOffice,
3202    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3203    /// typically indicates that this SDK version is out of date.
3204    Other,
3205}
3206
3207impl<'de> ::serde::de::Deserialize<'de> for MetadataType {
3208    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3209        // union deserializer
3210        use serde::de::{self, MapAccess, Visitor};
3211        struct EnumVisitor;
3212        impl<'de> Visitor<'de> for EnumVisitor {
3213            type Value = MetadataType;
3214            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3215                f.write_str("a MetadataType structure")
3216            }
3217            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3218                let tag: &str = match map.next_key()? {
3219                    Some(".tag") => map.next_value()?,
3220                    _ => return Err(de::Error::missing_field(".tag"))
3221                };
3222                let value = match tag {
3223                    "metadata_type_unknown" => MetadataType::MetadataTypeUnknown,
3224                    "metadata_type_exif" => MetadataType::MetadataTypeExif,
3225                    "metadata_type_media" => MetadataType::MetadataTypeMedia,
3226                    "metadata_type_pdf" => MetadataType::MetadataTypePdf,
3227                    "metadata_type_office" => MetadataType::MetadataTypeOffice,
3228                    _ => MetadataType::Other,
3229                };
3230                crate::eat_json_fields(&mut map)?;
3231                Ok(value)
3232            }
3233        }
3234        const VARIANTS: &[&str] = &["metadata_type_unknown",
3235                                    "metadata_type_exif",
3236                                    "metadata_type_media",
3237                                    "metadata_type_pdf",
3238                                    "metadata_type_office",
3239                                    "other"];
3240        deserializer.deserialize_struct("MetadataType", VARIANTS, EnumVisitor)
3241    }
3242}
3243
3244impl ::serde::ser::Serialize for MetadataType {
3245    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3246        // union serializer
3247        use serde::ser::SerializeStruct;
3248        match self {
3249            MetadataType::MetadataTypeUnknown => {
3250                // unit
3251                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3252                s.serialize_field(".tag", "metadata_type_unknown")?;
3253                s.end()
3254            }
3255            MetadataType::MetadataTypeExif => {
3256                // unit
3257                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3258                s.serialize_field(".tag", "metadata_type_exif")?;
3259                s.end()
3260            }
3261            MetadataType::MetadataTypeMedia => {
3262                // unit
3263                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3264                s.serialize_field(".tag", "metadata_type_media")?;
3265                s.end()
3266            }
3267            MetadataType::MetadataTypePdf => {
3268                // unit
3269                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3270                s.serialize_field(".tag", "metadata_type_pdf")?;
3271                s.end()
3272            }
3273            MetadataType::MetadataTypeOffice => {
3274                // unit
3275                let mut s = serializer.serialize_struct("MetadataType", 1)?;
3276                s.serialize_field(".tag", "metadata_type_office")?;
3277                s.end()
3278            }
3279            MetadataType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3280        }
3281    }
3282}
3283
3284/// The kind of MS Office document that produced an `ApiOfficeMetadata` result.
3285#[derive(Debug, Clone, PartialEq, Eq)]
3286#[non_exhaustive] // variants may be added in the future
3287pub enum OfficeFileType {
3288    OfficeFiletypeUnknown,
3289    OfficeFiletypeWord,
3290    OfficeFiletypePowerpoint,
3291    OfficeFiletypeExcel,
3292    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3293    /// typically indicates that this SDK version is out of date.
3294    Other,
3295}
3296
3297impl<'de> ::serde::de::Deserialize<'de> for OfficeFileType {
3298    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3299        // union deserializer
3300        use serde::de::{self, MapAccess, Visitor};
3301        struct EnumVisitor;
3302        impl<'de> Visitor<'de> for EnumVisitor {
3303            type Value = OfficeFileType;
3304            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3305                f.write_str("a OfficeFileType structure")
3306            }
3307            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3308                let tag: &str = match map.next_key()? {
3309                    Some(".tag") => map.next_value()?,
3310                    _ => return Err(de::Error::missing_field(".tag"))
3311                };
3312                let value = match tag {
3313                    "office_filetype_unknown" => OfficeFileType::OfficeFiletypeUnknown,
3314                    "office_filetype_word" => OfficeFileType::OfficeFiletypeWord,
3315                    "office_filetype_powerpoint" => OfficeFileType::OfficeFiletypePowerpoint,
3316                    "office_filetype_excel" => OfficeFileType::OfficeFiletypeExcel,
3317                    _ => OfficeFileType::Other,
3318                };
3319                crate::eat_json_fields(&mut map)?;
3320                Ok(value)
3321            }
3322        }
3323        const VARIANTS: &[&str] = &["office_filetype_unknown",
3324                                    "office_filetype_word",
3325                                    "office_filetype_powerpoint",
3326                                    "office_filetype_excel",
3327                                    "other"];
3328        deserializer.deserialize_struct("OfficeFileType", VARIANTS, EnumVisitor)
3329    }
3330}
3331
3332impl ::serde::ser::Serialize for OfficeFileType {
3333    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3334        // union serializer
3335        use serde::ser::SerializeStruct;
3336        match self {
3337            OfficeFileType::OfficeFiletypeUnknown => {
3338                // unit
3339                let mut s = serializer.serialize_struct("OfficeFileType", 1)?;
3340                s.serialize_field(".tag", "office_filetype_unknown")?;
3341                s.end()
3342            }
3343            OfficeFileType::OfficeFiletypeWord => {
3344                // unit
3345                let mut s = serializer.serialize_struct("OfficeFileType", 1)?;
3346                s.serialize_field(".tag", "office_filetype_word")?;
3347                s.end()
3348            }
3349            OfficeFileType::OfficeFiletypePowerpoint => {
3350                // unit
3351                let mut s = serializer.serialize_struct("OfficeFileType", 1)?;
3352                s.serialize_field(".tag", "office_filetype_powerpoint")?;
3353                s.end()
3354            }
3355            OfficeFileType::OfficeFiletypeExcel => {
3356                // unit
3357                let mut s = serializer.serialize_struct("OfficeFileType", 1)?;
3358                s.serialize_field(".tag", "office_filetype_excel")?;
3359                s.end()
3360            }
3361            OfficeFileType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3362        }
3363    }
3364}
3365
3366#[derive(Debug, Clone, PartialEq, Eq)]
3367#[non_exhaustive] // variants may be added in the future
3368pub enum TimestampLevel {
3369    Sentence,
3370    Word,
3371    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3372    /// typically indicates that this SDK version is out of date.
3373    Other,
3374}
3375
3376impl<'de> ::serde::de::Deserialize<'de> for TimestampLevel {
3377    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3378        // union deserializer
3379        use serde::de::{self, MapAccess, Visitor};
3380        struct EnumVisitor;
3381        impl<'de> Visitor<'de> for EnumVisitor {
3382            type Value = TimestampLevel;
3383            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3384                f.write_str("a TimestampLevel structure")
3385            }
3386            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3387                let tag: &str = match map.next_key()? {
3388                    Some(".tag") => map.next_value()?,
3389                    _ => return Err(de::Error::missing_field(".tag"))
3390                };
3391                let value = match tag {
3392                    "sentence" => TimestampLevel::Sentence,
3393                    "word" => TimestampLevel::Word,
3394                    _ => TimestampLevel::Other,
3395                };
3396                crate::eat_json_fields(&mut map)?;
3397                Ok(value)
3398            }
3399        }
3400        const VARIANTS: &[&str] = &["sentence",
3401                                    "word",
3402                                    "other"];
3403        deserializer.deserialize_struct("TimestampLevel", VARIANTS, EnumVisitor)
3404    }
3405}
3406
3407impl ::serde::ser::Serialize for TimestampLevel {
3408    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3409        // union serializer
3410        use serde::ser::SerializeStruct;
3411        match self {
3412            TimestampLevel::Sentence => {
3413                // unit
3414                let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
3415                s.serialize_field(".tag", "sentence")?;
3416                s.end()
3417            }
3418            TimestampLevel::Word => {
3419                // unit
3420                let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
3421                s.serialize_field(".tag", "word")?;
3422                s.end()
3423            }
3424            TimestampLevel::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3425        }
3426    }
3427}
3428
3429/// Exactly one variant is populated, corresponding to `metadata_type`.
3430#[derive(Debug, Clone, PartialEq)]
3431#[non_exhaustive] // variants may be added in the future
3432pub enum MetadataUnion {
3433    Exif(ApiExifMetadata),
3434    Media(ApiMediaMetadata),
3435    Pdf(ApiPdfMetadata),
3436    Office(ApiOfficeMetadata),
3437    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3438    /// typically indicates that this SDK version is out of date.
3439    Other,
3440}
3441
3442impl<'de> ::serde::de::Deserialize<'de> for MetadataUnion {
3443    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3444        // union deserializer
3445        use serde::de::{self, MapAccess, Visitor};
3446        struct EnumVisitor;
3447        impl<'de> Visitor<'de> for EnumVisitor {
3448            type Value = MetadataUnion;
3449            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3450                f.write_str("a metadata_union structure")
3451            }
3452            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3453                let tag: &str = match map.next_key()? {
3454                    Some(".tag") => map.next_value()?,
3455                    _ => return Err(de::Error::missing_field(".tag"))
3456                };
3457                let value = match tag {
3458                    "exif" => MetadataUnion::Exif(ApiExifMetadata::internal_deserialize(&mut map)?),
3459                    "media" => MetadataUnion::Media(ApiMediaMetadata::internal_deserialize(&mut map)?),
3460                    "pdf" => MetadataUnion::Pdf(ApiPdfMetadata::internal_deserialize(&mut map)?),
3461                    "office" => MetadataUnion::Office(ApiOfficeMetadata::internal_deserialize(&mut map)?),
3462                    _ => MetadataUnion::Other,
3463                };
3464                crate::eat_json_fields(&mut map)?;
3465                Ok(value)
3466            }
3467        }
3468        const VARIANTS: &[&str] = &["exif",
3469                                    "media",
3470                                    "pdf",
3471                                    "office",
3472                                    "other"];
3473        deserializer.deserialize_struct("metadata_union", VARIANTS, EnumVisitor)
3474    }
3475}
3476
3477impl ::serde::ser::Serialize for MetadataUnion {
3478    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3479        // union serializer
3480        use serde::ser::SerializeStruct;
3481        match self {
3482            MetadataUnion::Exif(x) => {
3483                // struct
3484                let mut s = serializer.serialize_struct("metadata_union", 17)?;
3485                s.serialize_field(".tag", "exif")?;
3486                x.internal_serialize::<S>(&mut s)?;
3487                s.end()
3488            }
3489            MetadataUnion::Media(x) => {
3490                // struct
3491                let mut s = serializer.serialize_struct("metadata_union", 5)?;
3492                s.serialize_field(".tag", "media")?;
3493                x.internal_serialize::<S>(&mut s)?;
3494                s.end()
3495            }
3496            MetadataUnion::Pdf(x) => {
3497                // struct
3498                let mut s = serializer.serialize_struct("metadata_union", 4)?;
3499                s.serialize_field(".tag", "pdf")?;
3500                x.internal_serialize::<S>(&mut s)?;
3501                s.end()
3502            }
3503            MetadataUnion::Office(x) => {
3504                // struct
3505                let mut s = serializer.serialize_struct("metadata_union", 13)?;
3506                s.serialize_field(".tag", "office")?;
3507                x.internal_serialize::<S>(&mut s)?;
3508                s.end()
3509            }
3510            MetadataUnion::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3511        }
3512    }
3513}
3514