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/// Structured transcript for APIv2
13#[derive(Debug, Clone, PartialEq, Default)]
14#[non_exhaustive] // structs may have more fields added in the future.
15pub struct ApiStructuredTranscript {
16    pub segments: Option<Vec<ApiTranscriptSegment>>,
17    pub transcript_locale: String,
18}
19
20impl ApiStructuredTranscript {
21    pub fn with_segments(mut self, value: Vec<ApiTranscriptSegment>) -> Self {
22        self.segments = Some(value);
23        self
24    }
25
26    pub fn with_transcript_locale(mut self, value: String) -> Self {
27        self.transcript_locale = value;
28        self
29    }
30}
31
32const API_STRUCTURED_TRANSCRIPT_FIELDS: &[&str] = &["segments",
33                                                    "transcript_locale"];
34impl ApiStructuredTranscript {
35    // no _opt deserializer
36    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
37        mut map: V,
38    ) -> Result<ApiStructuredTranscript, V::Error> {
39        let mut field_segments = None;
40        let mut field_transcript_locale = None;
41        while let Some(key) = map.next_key::<&str>()? {
42            match key {
43                "segments" => {
44                    if field_segments.is_some() {
45                        return Err(::serde::de::Error::duplicate_field("segments"));
46                    }
47                    field_segments = Some(map.next_value()?);
48                }
49                "transcript_locale" => {
50                    if field_transcript_locale.is_some() {
51                        return Err(::serde::de::Error::duplicate_field("transcript_locale"));
52                    }
53                    field_transcript_locale = Some(map.next_value()?);
54                }
55                _ => {
56                    // unknown field allowed and ignored
57                    map.next_value::<::serde_json::Value>()?;
58                }
59            }
60        }
61        let result = ApiStructuredTranscript {
62            segments: field_segments.and_then(Option::flatten),
63            transcript_locale: field_transcript_locale.unwrap_or_default(),
64        };
65        Ok(result)
66    }
67
68    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
69        &self,
70        s: &mut S::SerializeStruct,
71    ) -> Result<(), S::Error> {
72        use serde::ser::SerializeStruct;
73        if let Some(val) = &self.segments {
74            s.serialize_field("segments", val)?;
75        }
76        if !self.transcript_locale.is_empty() {
77            s.serialize_field("transcript_locale", &self.transcript_locale)?;
78        }
79        Ok(())
80    }
81}
82
83impl<'de> ::serde::de::Deserialize<'de> for ApiStructuredTranscript {
84    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
85        // struct deserializer
86        use serde::de::{MapAccess, Visitor};
87        struct StructVisitor;
88        impl<'de> Visitor<'de> for StructVisitor {
89            type Value = ApiStructuredTranscript;
90            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
91                f.write_str("a ApiStructuredTranscript struct")
92            }
93            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
94                ApiStructuredTranscript::internal_deserialize(map)
95            }
96        }
97        deserializer.deserialize_struct("ApiStructuredTranscript", API_STRUCTURED_TRANSCRIPT_FIELDS, StructVisitor)
98    }
99}
100
101impl ::serde::ser::Serialize for ApiStructuredTranscript {
102    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
103        // struct serializer
104        use serde::ser::SerializeStruct;
105        let mut s = serializer.serialize_struct("ApiStructuredTranscript", 2)?;
106        self.internal_serialize::<S>(&mut s)?;
107        s.end()
108    }
109}
110
111/// Transcript segment for APIv2
112#[derive(Debug, Clone, PartialEq, Default)]
113#[non_exhaustive] // structs may have more fields added in the future.
114pub struct ApiTranscriptSegment {
115    pub text: String,
116    pub start_time: f64,
117    pub end_time: f64,
118}
119
120impl ApiTranscriptSegment {
121    pub fn with_text(mut self, value: String) -> Self {
122        self.text = value;
123        self
124    }
125
126    pub fn with_start_time(mut self, value: f64) -> Self {
127        self.start_time = value;
128        self
129    }
130
131    pub fn with_end_time(mut self, value: f64) -> Self {
132        self.end_time = value;
133        self
134    }
135}
136
137const API_TRANSCRIPT_SEGMENT_FIELDS: &[&str] = &["text",
138                                                 "start_time",
139                                                 "end_time"];
140impl ApiTranscriptSegment {
141    // no _opt deserializer
142    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
143        mut map: V,
144    ) -> Result<ApiTranscriptSegment, V::Error> {
145        let mut field_text = None;
146        let mut field_start_time = None;
147        let mut field_end_time = None;
148        while let Some(key) = map.next_key::<&str>()? {
149            match key {
150                "text" => {
151                    if field_text.is_some() {
152                        return Err(::serde::de::Error::duplicate_field("text"));
153                    }
154                    field_text = Some(map.next_value()?);
155                }
156                "start_time" => {
157                    if field_start_time.is_some() {
158                        return Err(::serde::de::Error::duplicate_field("start_time"));
159                    }
160                    field_start_time = Some(map.next_value()?);
161                }
162                "end_time" => {
163                    if field_end_time.is_some() {
164                        return Err(::serde::de::Error::duplicate_field("end_time"));
165                    }
166                    field_end_time = Some(map.next_value()?);
167                }
168                _ => {
169                    // unknown field allowed and ignored
170                    map.next_value::<::serde_json::Value>()?;
171                }
172            }
173        }
174        let result = ApiTranscriptSegment {
175            text: field_text.unwrap_or_default(),
176            start_time: field_start_time.unwrap_or(0.0),
177            end_time: field_end_time.unwrap_or(0.0),
178        };
179        Ok(result)
180    }
181
182    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
183        &self,
184        s: &mut S::SerializeStruct,
185    ) -> Result<(), S::Error> {
186        use serde::ser::SerializeStruct;
187        if !self.text.is_empty() {
188            s.serialize_field("text", &self.text)?;
189        }
190        if self.start_time != 0.0 {
191            s.serialize_field("start_time", &self.start_time)?;
192        }
193        if self.end_time != 0.0 {
194            s.serialize_field("end_time", &self.end_time)?;
195        }
196        Ok(())
197    }
198}
199
200impl<'de> ::serde::de::Deserialize<'de> for ApiTranscriptSegment {
201    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
202        // struct deserializer
203        use serde::de::{MapAccess, Visitor};
204        struct StructVisitor;
205        impl<'de> Visitor<'de> for StructVisitor {
206            type Value = ApiTranscriptSegment;
207            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
208                f.write_str("a ApiTranscriptSegment struct")
209            }
210            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
211                ApiTranscriptSegment::internal_deserialize(map)
212            }
213        }
214        deserializer.deserialize_struct("ApiTranscriptSegment", API_TRANSCRIPT_SEGMENT_FIELDS, StructVisitor)
215    }
216}
217
218impl ::serde::ser::Serialize for ApiTranscriptSegment {
219    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
220        // struct serializer
221        use serde::ser::SerializeStruct;
222        let mut s = serializer.serialize_struct("ApiTranscriptSegment", 3)?;
223        self.internal_serialize::<S>(&mut s)?;
224        s.end()
225    }
226}
227
228#[derive(Debug, Clone, PartialEq, Eq)]
229#[non_exhaustive] // variants may be added in the future
230pub enum ContentApiV2Error {
231    ServerError(String),
232    UserError(String),
233    MediaDurationError(MediaDurationError),
234    NoAudioError,
235    LinkDownloadDisabledError,
236    SharedLinkPasswordProtected,
237    LimitExceededError,
238    /// Catch-all used for unrecognized values returned from the server. Encountering this value
239    /// typically indicates that this SDK version is out of date.
240    Other,
241}
242
243impl<'de> ::serde::de::Deserialize<'de> for ContentApiV2Error {
244    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
245        // union deserializer
246        use serde::de::{self, MapAccess, Visitor};
247        struct EnumVisitor;
248        impl<'de> Visitor<'de> for EnumVisitor {
249            type Value = ContentApiV2Error;
250            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
251                f.write_str("a ContentApiV2Error structure")
252            }
253            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
254                let tag: &str = match map.next_key()? {
255                    Some(".tag") => map.next_value()?,
256                    _ => return Err(de::Error::missing_field(".tag"))
257                };
258                let value = match tag {
259                    "server_error" => {
260                        match map.next_key()? {
261                            Some("server_error") => ContentApiV2Error::ServerError(map.next_value()?),
262                            None => return Err(de::Error::missing_field("server_error")),
263                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
264                        }
265                    }
266                    "user_error" => {
267                        match map.next_key()? {
268                            Some("user_error") => ContentApiV2Error::UserError(map.next_value()?),
269                            None => return Err(de::Error::missing_field("user_error")),
270                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
271                        }
272                    }
273                    "media_duration_error" => ContentApiV2Error::MediaDurationError(MediaDurationError::internal_deserialize(&mut map)?),
274                    "no_audio_error" => ContentApiV2Error::NoAudioError,
275                    "link_download_disabled_error" => ContentApiV2Error::LinkDownloadDisabledError,
276                    "shared_link_password_protected" => ContentApiV2Error::SharedLinkPasswordProtected,
277                    "limit_exceeded_error" => ContentApiV2Error::LimitExceededError,
278                    _ => ContentApiV2Error::Other,
279                };
280                crate::eat_json_fields(&mut map)?;
281                Ok(value)
282            }
283        }
284        const VARIANTS: &[&str] = &["server_error",
285                                    "user_error",
286                                    "media_duration_error",
287                                    "no_audio_error",
288                                    "link_download_disabled_error",
289                                    "shared_link_password_protected",
290                                    "limit_exceeded_error",
291                                    "other"];
292        deserializer.deserialize_struct("ContentApiV2Error", VARIANTS, EnumVisitor)
293    }
294}
295
296impl ::serde::ser::Serialize for ContentApiV2Error {
297    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
298        // union serializer
299        use serde::ser::SerializeStruct;
300        match self {
301            ContentApiV2Error::ServerError(x) => {
302                // primitive
303                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
304                s.serialize_field(".tag", "server_error")?;
305                s.serialize_field("server_error", x)?;
306                s.end()
307            }
308            ContentApiV2Error::UserError(x) => {
309                // primitive
310                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
311                s.serialize_field(".tag", "user_error")?;
312                s.serialize_field("user_error", x)?;
313                s.end()
314            }
315            ContentApiV2Error::MediaDurationError(x) => {
316                // struct
317                let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
318                s.serialize_field(".tag", "media_duration_error")?;
319                x.internal_serialize::<S>(&mut s)?;
320                s.end()
321            }
322            ContentApiV2Error::NoAudioError => {
323                // unit
324                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
325                s.serialize_field(".tag", "no_audio_error")?;
326                s.end()
327            }
328            ContentApiV2Error::LinkDownloadDisabledError => {
329                // unit
330                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
331                s.serialize_field(".tag", "link_download_disabled_error")?;
332                s.end()
333            }
334            ContentApiV2Error::SharedLinkPasswordProtected => {
335                // unit
336                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
337                s.serialize_field(".tag", "shared_link_password_protected")?;
338                s.end()
339            }
340            ContentApiV2Error::LimitExceededError => {
341                // unit
342                let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
343                s.serialize_field(".tag", "limit_exceeded_error")?;
344                s.end()
345            }
346            ContentApiV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
347        }
348    }
349}
350
351impl ::std::error::Error for ContentApiV2Error {
352}
353
354impl ::std::fmt::Display for ContentApiV2Error {
355    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
356        match self {
357            ContentApiV2Error::ServerError(inner) => write!(f, "server_error: {:?}", inner),
358            ContentApiV2Error::UserError(inner) => write!(f, "user_error: {:?}", inner),
359            ContentApiV2Error::MediaDurationError(inner) => write!(f, "media_duration_error: {:?}", inner),
360            _ => write!(f, "{:?}", *self),
361        }
362    }
363}
364
365#[derive(Debug, Clone, PartialEq, Eq)]
366#[non_exhaustive] // variants may be added in the future
367pub enum ErrorCode {
368    UnknownError,
369    /// 400
370    BadRequest,
371    /// 409
372    ApiError,
373    /// 403
374    AccessError,
375    /// 429
376    RatelimitError,
377    /// 503
378    Unavailable,
379    /// Catch-all used for unrecognized values returned from the server. Encountering this value
380    /// typically indicates that this SDK version is out of date.
381    Other,
382}
383
384impl<'de> ::serde::de::Deserialize<'de> for ErrorCode {
385    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
386        // union deserializer
387        use serde::de::{self, MapAccess, Visitor};
388        struct EnumVisitor;
389        impl<'de> Visitor<'de> for EnumVisitor {
390            type Value = ErrorCode;
391            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
392                f.write_str("a ErrorCode structure")
393            }
394            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
395                let tag: &str = match map.next_key()? {
396                    Some(".tag") => map.next_value()?,
397                    _ => return Err(de::Error::missing_field(".tag"))
398                };
399                let value = match tag {
400                    "unknown_error" => ErrorCode::UnknownError,
401                    "bad_request" => ErrorCode::BadRequest,
402                    "api_error" => ErrorCode::ApiError,
403                    "access_error" => ErrorCode::AccessError,
404                    "ratelimit_error" => ErrorCode::RatelimitError,
405                    "unavailable" => ErrorCode::Unavailable,
406                    _ => ErrorCode::Other,
407                };
408                crate::eat_json_fields(&mut map)?;
409                Ok(value)
410            }
411        }
412        const VARIANTS: &[&str] = &["unknown_error",
413                                    "bad_request",
414                                    "api_error",
415                                    "access_error",
416                                    "ratelimit_error",
417                                    "unavailable",
418                                    "other"];
419        deserializer.deserialize_struct("ErrorCode", VARIANTS, EnumVisitor)
420    }
421}
422
423impl ::serde::ser::Serialize for ErrorCode {
424    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
425        // union serializer
426        use serde::ser::SerializeStruct;
427        match self {
428            ErrorCode::UnknownError => {
429                // unit
430                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
431                s.serialize_field(".tag", "unknown_error")?;
432                s.end()
433            }
434            ErrorCode::BadRequest => {
435                // unit
436                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
437                s.serialize_field(".tag", "bad_request")?;
438                s.end()
439            }
440            ErrorCode::ApiError => {
441                // unit
442                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
443                s.serialize_field(".tag", "api_error")?;
444                s.end()
445            }
446            ErrorCode::AccessError => {
447                // unit
448                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
449                s.serialize_field(".tag", "access_error")?;
450                s.end()
451            }
452            ErrorCode::RatelimitError => {
453                // unit
454                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
455                s.serialize_field(".tag", "ratelimit_error")?;
456                s.end()
457            }
458            ErrorCode::Unavailable => {
459                // unit
460                let mut s = serializer.serialize_struct("ErrorCode", 1)?;
461                s.serialize_field(".tag", "unavailable")?;
462                s.end()
463            }
464            ErrorCode::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
465        }
466    }
467}
468
469#[derive(Debug, Clone, PartialEq, Eq)]
470#[non_exhaustive] // variants may be added in the future
471pub enum FileIdOrUrl {
472    FileId(String),
473    Url(String),
474    Path(String),
475    /// Catch-all used for unrecognized values returned from the server. Encountering this value
476    /// typically indicates that this SDK version is out of date.
477    Other,
478}
479
480impl<'de> ::serde::de::Deserialize<'de> for FileIdOrUrl {
481    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
482        // union deserializer
483        use serde::de::{self, MapAccess, Visitor};
484        struct EnumVisitor;
485        impl<'de> Visitor<'de> for EnumVisitor {
486            type Value = FileIdOrUrl;
487            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
488                f.write_str("a FileIdOrUrl structure")
489            }
490            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
491                let tag: &str = match map.next_key()? {
492                    Some(".tag") => map.next_value()?,
493                    _ => return Err(de::Error::missing_field(".tag"))
494                };
495                let value = match tag {
496                    "file_id" => {
497                        match map.next_key()? {
498                            Some("file_id") => FileIdOrUrl::FileId(map.next_value()?),
499                            None => return Err(de::Error::missing_field("file_id")),
500                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
501                        }
502                    }
503                    "url" => {
504                        match map.next_key()? {
505                            Some("url") => FileIdOrUrl::Url(map.next_value()?),
506                            None => return Err(de::Error::missing_field("url")),
507                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
508                        }
509                    }
510                    "path" => {
511                        match map.next_key()? {
512                            Some("path") => FileIdOrUrl::Path(map.next_value()?),
513                            None => return Err(de::Error::missing_field("path")),
514                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
515                        }
516                    }
517                    _ => FileIdOrUrl::Other,
518                };
519                crate::eat_json_fields(&mut map)?;
520                Ok(value)
521            }
522        }
523        const VARIANTS: &[&str] = &["file_id",
524                                    "url",
525                                    "path",
526                                    "other"];
527        deserializer.deserialize_struct("FileIdOrUrl", VARIANTS, EnumVisitor)
528    }
529}
530
531impl ::serde::ser::Serialize for FileIdOrUrl {
532    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
533        // union serializer
534        use serde::ser::SerializeStruct;
535        match self {
536            FileIdOrUrl::FileId(x) => {
537                // primitive
538                let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
539                s.serialize_field(".tag", "file_id")?;
540                s.serialize_field("file_id", x)?;
541                s.end()
542            }
543            FileIdOrUrl::Url(x) => {
544                // primitive
545                let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
546                s.serialize_field(".tag", "url")?;
547                s.serialize_field("url", x)?;
548                s.end()
549            }
550            FileIdOrUrl::Path(x) => {
551                // primitive
552                let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
553                s.serialize_field(".tag", "path")?;
554                s.serialize_field("path", x)?;
555                s.end()
556            }
557            FileIdOrUrl::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
558        }
559    }
560}
561
562/// Arguments for the asynchronous `get_transcript_async` route. Exactly one of `file_id`, `path`,
563/// or `url` must be supplied via `file_id_or_url` to identify the audio or video asset to
564/// transcribe.
565#[derive(Debug, Clone, PartialEq, Eq)]
566#[non_exhaustive] // structs may have more fields added in the future.
567pub struct GetTranscriptArgs {
568    /// Identifier of the media asset to transcribe. Callers must set exactly one of the oneof
569    /// variants: - file_id: a Dropbox-issued file id (format: "id:<id>") for a file the
570    /// authenticated user has access to. - path: an absolute Dropbox path, e.g.
571    /// "/folder/recording.mp4". - url: either a Dropbox shared link (www.dropbox.com) or an
572    /// external HTTPS URL pointing to a supported audio/video file. - Dropbox shared links are
573    /// resolved internally using the caller's authenticated identity and the link's visibility /
574    /// download settings. They therefore require an authenticated user context (anonymous `url`
575    /// requests against Dropbox links are rejected with an `ACCESS_ERROR`). Links protected by a
576    /// password are rejected with `shared_link_password_protected`; links with downloads disabled
577    /// are rejected with `link_download_disabled_error`. - External URLs are fetched over HTTPS
578    /// through the backend's egress proxy and must point at a supported audio/video file extension.
579    /// The referenced asset must be an audio or video file in a supported format; requests against
580    /// files with no audio track return a `no_audio_error`.
581    pub file_id_or_url: Option<FileIdOrUrl>,
582    /// Granularity of the time offsets returned for each transcript segment. Defaults to `SENTENCE.
583    /// - SENTENCE: one segment per spoken sentence (recommended). - WORD: one segment per word,
584    /// useful for fine-grained alignment such as captioning or highlight-as-you-listen experiences.
585    pub timestamp_level: TimestampLevel,
586    /// Comma-delimited list of non-lexical filler words to preserve in the transcript output, e.g.
587    /// `"uh, ah, uhm"`. By default these fillers are stripped. Unrecognized tokens are ignored.
588    /// Leave empty to use the default filtering behavior.
589    pub included_special_words: String,
590    /// Optional BCP-47 language tag hinting the spoken language of the source audio (e.g. "en-US",
591    /// "ja-JP"). When empty, the service auto-detects the language; supplying a hint improves
592    /// accuracy and latency for short or ambiguous clips. Unsupported languages fall back to
593    /// auto-detection.
594    pub audio_language: String,
595}
596
597impl Default for GetTranscriptArgs {
598    fn default() -> Self {
599        GetTranscriptArgs {
600            file_id_or_url: None,
601            timestamp_level: TimestampLevel::Unknown,
602            included_special_words: String::new(),
603            audio_language: String::new(),
604        }
605    }
606}
607
608impl GetTranscriptArgs {
609    pub fn with_file_id_or_url(mut self, value: FileIdOrUrl) -> Self {
610        self.file_id_or_url = Some(value);
611        self
612    }
613
614    pub fn with_timestamp_level(mut self, value: TimestampLevel) -> Self {
615        self.timestamp_level = value;
616        self
617    }
618
619    pub fn with_included_special_words(mut self, value: String) -> Self {
620        self.included_special_words = value;
621        self
622    }
623
624    pub fn with_audio_language(mut self, value: String) -> Self {
625        self.audio_language = value;
626        self
627    }
628}
629
630const GET_TRANSCRIPT_ARGS_FIELDS: &[&str] = &["file_id_or_url",
631                                              "timestamp_level",
632                                              "included_special_words",
633                                              "audio_language"];
634impl GetTranscriptArgs {
635    // no _opt deserializer
636    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
637        mut map: V,
638    ) -> Result<GetTranscriptArgs, V::Error> {
639        let mut field_file_id_or_url = None;
640        let mut field_timestamp_level = None;
641        let mut field_included_special_words = None;
642        let mut field_audio_language = None;
643        while let Some(key) = map.next_key::<&str>()? {
644            match key {
645                "file_id_or_url" => {
646                    if field_file_id_or_url.is_some() {
647                        return Err(::serde::de::Error::duplicate_field("file_id_or_url"));
648                    }
649                    field_file_id_or_url = Some(map.next_value()?);
650                }
651                "timestamp_level" => {
652                    if field_timestamp_level.is_some() {
653                        return Err(::serde::de::Error::duplicate_field("timestamp_level"));
654                    }
655                    field_timestamp_level = Some(map.next_value()?);
656                }
657                "included_special_words" => {
658                    if field_included_special_words.is_some() {
659                        return Err(::serde::de::Error::duplicate_field("included_special_words"));
660                    }
661                    field_included_special_words = Some(map.next_value()?);
662                }
663                "audio_language" => {
664                    if field_audio_language.is_some() {
665                        return Err(::serde::de::Error::duplicate_field("audio_language"));
666                    }
667                    field_audio_language = Some(map.next_value()?);
668                }
669                _ => {
670                    // unknown field allowed and ignored
671                    map.next_value::<::serde_json::Value>()?;
672                }
673            }
674        }
675        let result = GetTranscriptArgs {
676            file_id_or_url: field_file_id_or_url.and_then(Option::flatten),
677            timestamp_level: field_timestamp_level.unwrap_or(TimestampLevel::Unknown),
678            included_special_words: field_included_special_words.unwrap_or_default(),
679            audio_language: field_audio_language.unwrap_or_default(),
680        };
681        Ok(result)
682    }
683
684    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
685        &self,
686        s: &mut S::SerializeStruct,
687    ) -> Result<(), S::Error> {
688        use serde::ser::SerializeStruct;
689        if let Some(val) = &self.file_id_or_url {
690            s.serialize_field("file_id_or_url", val)?;
691        }
692        if self.timestamp_level != TimestampLevel::Unknown {
693            s.serialize_field("timestamp_level", &self.timestamp_level)?;
694        }
695        if !self.included_special_words.is_empty() {
696            s.serialize_field("included_special_words", &self.included_special_words)?;
697        }
698        if !self.audio_language.is_empty() {
699            s.serialize_field("audio_language", &self.audio_language)?;
700        }
701        Ok(())
702    }
703}
704
705impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptArgs {
706    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
707        // struct deserializer
708        use serde::de::{MapAccess, Visitor};
709        struct StructVisitor;
710        impl<'de> Visitor<'de> for StructVisitor {
711            type Value = GetTranscriptArgs;
712            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
713                f.write_str("a GetTranscriptArgs struct")
714            }
715            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
716                GetTranscriptArgs::internal_deserialize(map)
717            }
718        }
719        deserializer.deserialize_struct("GetTranscriptArgs", GET_TRANSCRIPT_ARGS_FIELDS, StructVisitor)
720    }
721}
722
723impl ::serde::ser::Serialize for GetTranscriptArgs {
724    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
725        // struct serializer
726        use serde::ser::SerializeStruct;
727        let mut s = serializer.serialize_struct("GetTranscriptArgs", 4)?;
728        self.internal_serialize::<S>(&mut s)?;
729        s.end()
730    }
731}
732
733/// Result type for EventBus async check - must end in "CheckResult"
734#[derive(Debug, Clone, PartialEq)]
735#[non_exhaustive] // variants may be added in the future
736pub enum GetTranscriptAsyncCheckResult {
737    InProgress,
738    Complete(GetTranscriptResult),
739    Failed(GetTranscriptAsyncError),
740    /// Catch-all used for unrecognized values returned from the server. Encountering this value
741    /// typically indicates that this SDK version is out of date.
742    Other,
743}
744
745impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptAsyncCheckResult {
746    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
747        // union deserializer
748        use serde::de::{self, MapAccess, Visitor};
749        struct EnumVisitor;
750        impl<'de> Visitor<'de> for EnumVisitor {
751            type Value = GetTranscriptAsyncCheckResult;
752            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
753                f.write_str("a GetTranscriptAsyncCheckResult structure")
754            }
755            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
756                let tag: &str = match map.next_key()? {
757                    Some(".tag") => map.next_value()?,
758                    _ => return Err(de::Error::missing_field(".tag"))
759                };
760                let value = match tag {
761                    "in_progress" => GetTranscriptAsyncCheckResult::InProgress,
762                    "complete" => GetTranscriptAsyncCheckResult::Complete(GetTranscriptResult::internal_deserialize(&mut map)?),
763                    "failed" => GetTranscriptAsyncCheckResult::Failed(GetTranscriptAsyncError::internal_deserialize(&mut map)?),
764                    _ => GetTranscriptAsyncCheckResult::Other,
765                };
766                crate::eat_json_fields(&mut map)?;
767                Ok(value)
768            }
769        }
770        const VARIANTS: &[&str] = &["in_progress",
771                                    "complete",
772                                    "failed",
773                                    "other"];
774        deserializer.deserialize_struct("GetTranscriptAsyncCheckResult", VARIANTS, EnumVisitor)
775    }
776}
777
778impl ::serde::ser::Serialize for GetTranscriptAsyncCheckResult {
779    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
780        // union serializer
781        use serde::ser::SerializeStruct;
782        match self {
783            GetTranscriptAsyncCheckResult::InProgress => {
784                // unit
785                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 1)?;
786                s.serialize_field(".tag", "in_progress")?;
787                s.end()
788            }
789            GetTranscriptAsyncCheckResult::Complete(x) => {
790                // struct
791                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 2)?;
792                s.serialize_field(".tag", "complete")?;
793                x.internal_serialize::<S>(&mut s)?;
794                s.end()
795            }
796            GetTranscriptAsyncCheckResult::Failed(x) => {
797                // struct
798                let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 3)?;
799                s.serialize_field(".tag", "failed")?;
800                x.internal_serialize::<S>(&mut s)?;
801                s.end()
802            }
803            GetTranscriptAsyncCheckResult::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
804        }
805    }
806}
807
808#[derive(Debug, Clone, PartialEq, Eq)]
809#[non_exhaustive] // structs may have more fields added in the future.
810pub struct GetTranscriptAsyncError {
811    pub error_code: ErrorCode,
812    pub error_details: Option<ContentApiV2Error>,
813}
814
815impl Default for GetTranscriptAsyncError {
816    fn default() -> Self {
817        GetTranscriptAsyncError {
818            error_code: ErrorCode::UnknownError,
819            error_details: None,
820        }
821    }
822}
823
824impl GetTranscriptAsyncError {
825    pub fn with_error_code(mut self, value: ErrorCode) -> Self {
826        self.error_code = value;
827        self
828    }
829
830    pub fn with_error_details(mut self, value: ContentApiV2Error) -> Self {
831        self.error_details = Some(value);
832        self
833    }
834}
835
836const GET_TRANSCRIPT_ASYNC_ERROR_FIELDS: &[&str] = &["error_code",
837                                                     "error_details"];
838impl GetTranscriptAsyncError {
839    // no _opt deserializer
840    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
841        mut map: V,
842    ) -> Result<GetTranscriptAsyncError, V::Error> {
843        let mut field_error_code = None;
844        let mut field_error_details = None;
845        while let Some(key) = map.next_key::<&str>()? {
846            match key {
847                "error_code" => {
848                    if field_error_code.is_some() {
849                        return Err(::serde::de::Error::duplicate_field("error_code"));
850                    }
851                    field_error_code = Some(map.next_value()?);
852                }
853                "error_details" => {
854                    if field_error_details.is_some() {
855                        return Err(::serde::de::Error::duplicate_field("error_details"));
856                    }
857                    field_error_details = Some(map.next_value()?);
858                }
859                _ => {
860                    // unknown field allowed and ignored
861                    map.next_value::<::serde_json::Value>()?;
862                }
863            }
864        }
865        let result = GetTranscriptAsyncError {
866            error_code: field_error_code.unwrap_or(ErrorCode::UnknownError),
867            error_details: field_error_details.and_then(Option::flatten),
868        };
869        Ok(result)
870    }
871
872    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
873        &self,
874        s: &mut S::SerializeStruct,
875    ) -> Result<(), S::Error> {
876        use serde::ser::SerializeStruct;
877        if self.error_code != ErrorCode::UnknownError {
878            s.serialize_field("error_code", &self.error_code)?;
879        }
880        if let Some(val) = &self.error_details {
881            s.serialize_field("error_details", val)?;
882        }
883        Ok(())
884    }
885}
886
887impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptAsyncError {
888    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
889        // struct deserializer
890        use serde::de::{MapAccess, Visitor};
891        struct StructVisitor;
892        impl<'de> Visitor<'de> for StructVisitor {
893            type Value = GetTranscriptAsyncError;
894            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
895                f.write_str("a GetTranscriptAsyncError struct")
896            }
897            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
898                GetTranscriptAsyncError::internal_deserialize(map)
899            }
900        }
901        deserializer.deserialize_struct("GetTranscriptAsyncError", GET_TRANSCRIPT_ASYNC_ERROR_FIELDS, StructVisitor)
902    }
903}
904
905impl ::serde::ser::Serialize for GetTranscriptAsyncError {
906    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
907        // struct serializer
908        use serde::ser::SerializeStruct;
909        let mut s = serializer.serialize_struct("GetTranscriptAsyncError", 2)?;
910        self.internal_serialize::<S>(&mut s)?;
911        s.end()
912    }
913}
914
915#[derive(Debug, Clone, PartialEq, Default)]
916#[non_exhaustive] // structs may have more fields added in the future.
917pub struct GetTranscriptResult {
918    /// The structured transcript produced for the requested media asset, with per-segment text,
919    /// start/end offsets (in seconds from the beginning of the media), and the detected or
920    /// caller-supplied locale.
921    pub structured_transcript: Option<ApiStructuredTranscript>,
922}
923
924impl GetTranscriptResult {
925    pub fn with_structured_transcript(mut self, value: ApiStructuredTranscript) -> Self {
926        self.structured_transcript = Some(value);
927        self
928    }
929}
930
931const GET_TRANSCRIPT_RESULT_FIELDS: &[&str] = &["structured_transcript"];
932impl GetTranscriptResult {
933    // no _opt deserializer
934    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
935        mut map: V,
936    ) -> Result<GetTranscriptResult, V::Error> {
937        let mut field_structured_transcript = None;
938        while let Some(key) = map.next_key::<&str>()? {
939            match key {
940                "structured_transcript" => {
941                    if field_structured_transcript.is_some() {
942                        return Err(::serde::de::Error::duplicate_field("structured_transcript"));
943                    }
944                    field_structured_transcript = Some(map.next_value()?);
945                }
946                _ => {
947                    // unknown field allowed and ignored
948                    map.next_value::<::serde_json::Value>()?;
949                }
950            }
951        }
952        let result = GetTranscriptResult {
953            structured_transcript: field_structured_transcript.and_then(Option::flatten),
954        };
955        Ok(result)
956    }
957
958    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
959        &self,
960        s: &mut S::SerializeStruct,
961    ) -> Result<(), S::Error> {
962        use serde::ser::SerializeStruct;
963        if let Some(val) = &self.structured_transcript {
964            s.serialize_field("structured_transcript", val)?;
965        }
966        Ok(())
967    }
968}
969
970impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptResult {
971    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
972        // struct deserializer
973        use serde::de::{MapAccess, Visitor};
974        struct StructVisitor;
975        impl<'de> Visitor<'de> for StructVisitor {
976            type Value = GetTranscriptResult;
977            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
978                f.write_str("a GetTranscriptResult struct")
979            }
980            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
981                GetTranscriptResult::internal_deserialize(map)
982            }
983        }
984        deserializer.deserialize_struct("GetTranscriptResult", GET_TRANSCRIPT_RESULT_FIELDS, StructVisitor)
985    }
986}
987
988impl ::serde::ser::Serialize for GetTranscriptResult {
989    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
990        // struct serializer
991        use serde::ser::SerializeStruct;
992        let mut s = serializer.serialize_struct("GetTranscriptResult", 1)?;
993        self.internal_serialize::<S>(&mut s)?;
994        s.end()
995    }
996}
997
998#[derive(Debug, Clone, PartialEq, Eq, Default)]
999#[non_exhaustive] // structs may have more fields added in the future.
1000pub struct MediaDurationError {
1001    pub limit: i32,
1002}
1003
1004impl MediaDurationError {
1005    pub fn with_limit(mut self, value: i32) -> Self {
1006        self.limit = value;
1007        self
1008    }
1009}
1010
1011const MEDIA_DURATION_ERROR_FIELDS: &[&str] = &["limit"];
1012impl MediaDurationError {
1013    // no _opt deserializer
1014    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1015        mut map: V,
1016    ) -> Result<MediaDurationError, V::Error> {
1017        let mut field_limit = None;
1018        while let Some(key) = map.next_key::<&str>()? {
1019            match key {
1020                "limit" => {
1021                    if field_limit.is_some() {
1022                        return Err(::serde::de::Error::duplicate_field("limit"));
1023                    }
1024                    field_limit = Some(map.next_value()?);
1025                }
1026                _ => {
1027                    // unknown field allowed and ignored
1028                    map.next_value::<::serde_json::Value>()?;
1029                }
1030            }
1031        }
1032        let result = MediaDurationError {
1033            limit: field_limit.unwrap_or(0),
1034        };
1035        Ok(result)
1036    }
1037
1038    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1039        &self,
1040        s: &mut S::SerializeStruct,
1041    ) -> Result<(), S::Error> {
1042        use serde::ser::SerializeStruct;
1043        if self.limit != 0 {
1044            s.serialize_field("limit", &self.limit)?;
1045        }
1046        Ok(())
1047    }
1048}
1049
1050impl<'de> ::serde::de::Deserialize<'de> for MediaDurationError {
1051    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1052        // struct deserializer
1053        use serde::de::{MapAccess, Visitor};
1054        struct StructVisitor;
1055        impl<'de> Visitor<'de> for StructVisitor {
1056            type Value = MediaDurationError;
1057            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1058                f.write_str("a MediaDurationError struct")
1059            }
1060            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1061                MediaDurationError::internal_deserialize(map)
1062            }
1063        }
1064        deserializer.deserialize_struct("MediaDurationError", MEDIA_DURATION_ERROR_FIELDS, StructVisitor)
1065    }
1066}
1067
1068impl ::serde::ser::Serialize for MediaDurationError {
1069    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1070        // struct serializer
1071        use serde::ser::SerializeStruct;
1072        let mut s = serializer.serialize_struct("MediaDurationError", 1)?;
1073        self.internal_serialize::<S>(&mut s)?;
1074        s.end()
1075    }
1076}
1077
1078#[derive(Debug, Clone, PartialEq, Eq)]
1079#[non_exhaustive] // variants may be added in the future
1080pub enum TimestampLevel {
1081    Unknown,
1082    Sentence,
1083    Word,
1084    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1085    /// typically indicates that this SDK version is out of date.
1086    Other,
1087}
1088
1089impl<'de> ::serde::de::Deserialize<'de> for TimestampLevel {
1090    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1091        // union deserializer
1092        use serde::de::{self, MapAccess, Visitor};
1093        struct EnumVisitor;
1094        impl<'de> Visitor<'de> for EnumVisitor {
1095            type Value = TimestampLevel;
1096            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1097                f.write_str("a TimestampLevel structure")
1098            }
1099            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1100                let tag: &str = match map.next_key()? {
1101                    Some(".tag") => map.next_value()?,
1102                    _ => return Err(de::Error::missing_field(".tag"))
1103                };
1104                let value = match tag {
1105                    "unknown" => TimestampLevel::Unknown,
1106                    "sentence" => TimestampLevel::Sentence,
1107                    "word" => TimestampLevel::Word,
1108                    _ => TimestampLevel::Other,
1109                };
1110                crate::eat_json_fields(&mut map)?;
1111                Ok(value)
1112            }
1113        }
1114        const VARIANTS: &[&str] = &["unknown",
1115                                    "sentence",
1116                                    "word",
1117                                    "other"];
1118        deserializer.deserialize_struct("TimestampLevel", VARIANTS, EnumVisitor)
1119    }
1120}
1121
1122impl ::serde::ser::Serialize for TimestampLevel {
1123    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1124        // union serializer
1125        use serde::ser::SerializeStruct;
1126        match self {
1127            TimestampLevel::Unknown => {
1128                // unit
1129                let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
1130                s.serialize_field(".tag", "unknown")?;
1131                s.end()
1132            }
1133            TimestampLevel::Sentence => {
1134                // unit
1135                let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
1136                s.serialize_field(".tag", "sentence")?;
1137                s.end()
1138            }
1139            TimestampLevel::Word => {
1140                // unit
1141                let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
1142                s.serialize_field(".tag", "word")?;
1143                s.end()
1144            }
1145            TimestampLevel::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1146        }
1147    }
1148}
1149