#![allow(
clippy::too_many_arguments,
clippy::large_enum_variant,
clippy::result_large_err,
clippy::doc_markdown,
clippy::doc_lazy_continuation,
)]
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive] pub struct ApiStructuredTranscript {
pub segments: Option<Vec<ApiTranscriptSegment>>,
pub transcript_locale: String,
}
impl ApiStructuredTranscript {
pub fn with_segments(mut self, value: Vec<ApiTranscriptSegment>) -> Self {
self.segments = Some(value);
self
}
pub fn with_transcript_locale(mut self, value: String) -> Self {
self.transcript_locale = value;
self
}
}
const API_STRUCTURED_TRANSCRIPT_FIELDS: &[&str] = &["segments",
"transcript_locale"];
impl ApiStructuredTranscript {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<ApiStructuredTranscript, V::Error> {
let mut field_segments = None;
let mut field_transcript_locale = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"segments" => {
if field_segments.is_some() {
return Err(::serde::de::Error::duplicate_field("segments"));
}
field_segments = Some(map.next_value()?);
}
"transcript_locale" => {
if field_transcript_locale.is_some() {
return Err(::serde::de::Error::duplicate_field("transcript_locale"));
}
field_transcript_locale = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = ApiStructuredTranscript {
segments: field_segments.and_then(Option::flatten),
transcript_locale: field_transcript_locale.unwrap_or_default(),
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if let Some(val) = &self.segments {
s.serialize_field("segments", val)?;
}
if !self.transcript_locale.is_empty() {
s.serialize_field("transcript_locale", &self.transcript_locale)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ApiStructuredTranscript {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ApiStructuredTranscript;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ApiStructuredTranscript struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ApiStructuredTranscript::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ApiStructuredTranscript", API_STRUCTURED_TRANSCRIPT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ApiStructuredTranscript {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ApiStructuredTranscript", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive] pub struct ApiTranscriptSegment {
pub text: String,
pub start_time: f64,
pub end_time: f64,
}
impl ApiTranscriptSegment {
pub fn with_text(mut self, value: String) -> Self {
self.text = value;
self
}
pub fn with_start_time(mut self, value: f64) -> Self {
self.start_time = value;
self
}
pub fn with_end_time(mut self, value: f64) -> Self {
self.end_time = value;
self
}
}
const API_TRANSCRIPT_SEGMENT_FIELDS: &[&str] = &["text",
"start_time",
"end_time"];
impl ApiTranscriptSegment {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<ApiTranscriptSegment, V::Error> {
let mut field_text = None;
let mut field_start_time = None;
let mut field_end_time = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"text" => {
if field_text.is_some() {
return Err(::serde::de::Error::duplicate_field("text"));
}
field_text = Some(map.next_value()?);
}
"start_time" => {
if field_start_time.is_some() {
return Err(::serde::de::Error::duplicate_field("start_time"));
}
field_start_time = Some(map.next_value()?);
}
"end_time" => {
if field_end_time.is_some() {
return Err(::serde::de::Error::duplicate_field("end_time"));
}
field_end_time = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = ApiTranscriptSegment {
text: field_text.unwrap_or_default(),
start_time: field_start_time.unwrap_or(0.0),
end_time: field_end_time.unwrap_or(0.0),
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if !self.text.is_empty() {
s.serialize_field("text", &self.text)?;
}
if self.start_time != 0.0 {
s.serialize_field("start_time", &self.start_time)?;
}
if self.end_time != 0.0 {
s.serialize_field("end_time", &self.end_time)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ApiTranscriptSegment {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ApiTranscriptSegment;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ApiTranscriptSegment struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ApiTranscriptSegment::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ApiTranscriptSegment", API_TRANSCRIPT_SEGMENT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ApiTranscriptSegment {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ApiTranscriptSegment", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ContentApiV2Error {
ServerError(String),
UserError(String),
MediaDurationError(MediaDurationError),
NoAudioError,
LinkDownloadDisabledError,
SharedLinkPasswordProtected,
LimitExceededError,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ContentApiV2Error {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ContentApiV2Error;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ContentApiV2Error structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"server_error" => {
match map.next_key()? {
Some("server_error") => ContentApiV2Error::ServerError(map.next_value()?),
None => return Err(de::Error::missing_field("server_error")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"user_error" => {
match map.next_key()? {
Some("user_error") => ContentApiV2Error::UserError(map.next_value()?),
None => return Err(de::Error::missing_field("user_error")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"media_duration_error" => ContentApiV2Error::MediaDurationError(MediaDurationError::internal_deserialize(&mut map)?),
"no_audio_error" => ContentApiV2Error::NoAudioError,
"link_download_disabled_error" => ContentApiV2Error::LinkDownloadDisabledError,
"shared_link_password_protected" => ContentApiV2Error::SharedLinkPasswordProtected,
"limit_exceeded_error" => ContentApiV2Error::LimitExceededError,
_ => ContentApiV2Error::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["server_error",
"user_error",
"media_duration_error",
"no_audio_error",
"link_download_disabled_error",
"shared_link_password_protected",
"limit_exceeded_error",
"other"];
deserializer.deserialize_struct("ContentApiV2Error", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ContentApiV2Error {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match self {
ContentApiV2Error::ServerError(x) => {
let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
s.serialize_field(".tag", "server_error")?;
s.serialize_field("server_error", x)?;
s.end()
}
ContentApiV2Error::UserError(x) => {
let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
s.serialize_field(".tag", "user_error")?;
s.serialize_field("user_error", x)?;
s.end()
}
ContentApiV2Error::MediaDurationError(x) => {
let mut s = serializer.serialize_struct("ContentApiV2Error", 2)?;
s.serialize_field(".tag", "media_duration_error")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
ContentApiV2Error::NoAudioError => {
let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
s.serialize_field(".tag", "no_audio_error")?;
s.end()
}
ContentApiV2Error::LinkDownloadDisabledError => {
let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
s.serialize_field(".tag", "link_download_disabled_error")?;
s.end()
}
ContentApiV2Error::SharedLinkPasswordProtected => {
let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
s.serialize_field(".tag", "shared_link_password_protected")?;
s.end()
}
ContentApiV2Error::LimitExceededError => {
let mut s = serializer.serialize_struct("ContentApiV2Error", 1)?;
s.serialize_field(".tag", "limit_exceeded_error")?;
s.end()
}
ContentApiV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for ContentApiV2Error {
}
impl ::std::fmt::Display for ContentApiV2Error {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
ContentApiV2Error::ServerError(inner) => write!(f, "server_error: {:?}", inner),
ContentApiV2Error::UserError(inner) => write!(f, "user_error: {:?}", inner),
ContentApiV2Error::MediaDurationError(inner) => write!(f, "media_duration_error: {:?}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ErrorCode {
UnknownError,
BadRequest,
ApiError,
AccessError,
RatelimitError,
Unavailable,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ErrorCode {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ErrorCode;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ErrorCode structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"unknown_error" => ErrorCode::UnknownError,
"bad_request" => ErrorCode::BadRequest,
"api_error" => ErrorCode::ApiError,
"access_error" => ErrorCode::AccessError,
"ratelimit_error" => ErrorCode::RatelimitError,
"unavailable" => ErrorCode::Unavailable,
_ => ErrorCode::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["unknown_error",
"bad_request",
"api_error",
"access_error",
"ratelimit_error",
"unavailable",
"other"];
deserializer.deserialize_struct("ErrorCode", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ErrorCode {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match self {
ErrorCode::UnknownError => {
let mut s = serializer.serialize_struct("ErrorCode", 1)?;
s.serialize_field(".tag", "unknown_error")?;
s.end()
}
ErrorCode::BadRequest => {
let mut s = serializer.serialize_struct("ErrorCode", 1)?;
s.serialize_field(".tag", "bad_request")?;
s.end()
}
ErrorCode::ApiError => {
let mut s = serializer.serialize_struct("ErrorCode", 1)?;
s.serialize_field(".tag", "api_error")?;
s.end()
}
ErrorCode::AccessError => {
let mut s = serializer.serialize_struct("ErrorCode", 1)?;
s.serialize_field(".tag", "access_error")?;
s.end()
}
ErrorCode::RatelimitError => {
let mut s = serializer.serialize_struct("ErrorCode", 1)?;
s.serialize_field(".tag", "ratelimit_error")?;
s.end()
}
ErrorCode::Unavailable => {
let mut s = serializer.serialize_struct("ErrorCode", 1)?;
s.serialize_field(".tag", "unavailable")?;
s.end()
}
ErrorCode::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum FileIdOrUrl {
FileId(String),
Url(String),
Path(String),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for FileIdOrUrl {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = FileIdOrUrl;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FileIdOrUrl structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"file_id" => {
match map.next_key()? {
Some("file_id") => FileIdOrUrl::FileId(map.next_value()?),
None => return Err(de::Error::missing_field("file_id")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"url" => {
match map.next_key()? {
Some("url") => FileIdOrUrl::Url(map.next_value()?),
None => return Err(de::Error::missing_field("url")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"path" => {
match map.next_key()? {
Some("path") => FileIdOrUrl::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => FileIdOrUrl::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["file_id",
"url",
"path",
"other"];
deserializer.deserialize_struct("FileIdOrUrl", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for FileIdOrUrl {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match self {
FileIdOrUrl::FileId(x) => {
let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
s.serialize_field(".tag", "file_id")?;
s.serialize_field("file_id", x)?;
s.end()
}
FileIdOrUrl::Url(x) => {
let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
s.serialize_field(".tag", "url")?;
s.serialize_field("url", x)?;
s.end()
}
FileIdOrUrl::Path(x) => {
let mut s = serializer.serialize_struct("FileIdOrUrl", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
FileIdOrUrl::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct GetTranscriptArgs {
pub file_id_or_url: Option<FileIdOrUrl>,
pub timestamp_level: TimestampLevel,
pub included_special_words: String,
pub audio_language: String,
}
impl Default for GetTranscriptArgs {
fn default() -> Self {
GetTranscriptArgs {
file_id_or_url: None,
timestamp_level: TimestampLevel::Unknown,
included_special_words: String::new(),
audio_language: String::new(),
}
}
}
impl GetTranscriptArgs {
pub fn with_file_id_or_url(mut self, value: FileIdOrUrl) -> Self {
self.file_id_or_url = Some(value);
self
}
pub fn with_timestamp_level(mut self, value: TimestampLevel) -> Self {
self.timestamp_level = value;
self
}
pub fn with_included_special_words(mut self, value: String) -> Self {
self.included_special_words = value;
self
}
pub fn with_audio_language(mut self, value: String) -> Self {
self.audio_language = value;
self
}
}
const GET_TRANSCRIPT_ARGS_FIELDS: &[&str] = &["file_id_or_url",
"timestamp_level",
"included_special_words",
"audio_language"];
impl GetTranscriptArgs {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<GetTranscriptArgs, V::Error> {
let mut field_file_id_or_url = None;
let mut field_timestamp_level = None;
let mut field_included_special_words = None;
let mut field_audio_language = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"file_id_or_url" => {
if field_file_id_or_url.is_some() {
return Err(::serde::de::Error::duplicate_field("file_id_or_url"));
}
field_file_id_or_url = Some(map.next_value()?);
}
"timestamp_level" => {
if field_timestamp_level.is_some() {
return Err(::serde::de::Error::duplicate_field("timestamp_level"));
}
field_timestamp_level = Some(map.next_value()?);
}
"included_special_words" => {
if field_included_special_words.is_some() {
return Err(::serde::de::Error::duplicate_field("included_special_words"));
}
field_included_special_words = Some(map.next_value()?);
}
"audio_language" => {
if field_audio_language.is_some() {
return Err(::serde::de::Error::duplicate_field("audio_language"));
}
field_audio_language = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = GetTranscriptArgs {
file_id_or_url: field_file_id_or_url.and_then(Option::flatten),
timestamp_level: field_timestamp_level.unwrap_or(TimestampLevel::Unknown),
included_special_words: field_included_special_words.unwrap_or_default(),
audio_language: field_audio_language.unwrap_or_default(),
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if let Some(val) = &self.file_id_or_url {
s.serialize_field("file_id_or_url", val)?;
}
if self.timestamp_level != TimestampLevel::Unknown {
s.serialize_field("timestamp_level", &self.timestamp_level)?;
}
if !self.included_special_words.is_empty() {
s.serialize_field("included_special_words", &self.included_special_words)?;
}
if !self.audio_language.is_empty() {
s.serialize_field("audio_language", &self.audio_language)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptArgs {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetTranscriptArgs;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTranscriptArgs struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetTranscriptArgs::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetTranscriptArgs", GET_TRANSCRIPT_ARGS_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetTranscriptArgs {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetTranscriptArgs", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub enum GetTranscriptAsyncCheckResult {
InProgress,
Complete(GetTranscriptResult),
Failed(GetTranscriptAsyncError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptAsyncCheckResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = GetTranscriptAsyncCheckResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTranscriptAsyncCheckResult structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"in_progress" => GetTranscriptAsyncCheckResult::InProgress,
"complete" => GetTranscriptAsyncCheckResult::Complete(GetTranscriptResult::internal_deserialize(&mut map)?),
"failed" => GetTranscriptAsyncCheckResult::Failed(GetTranscriptAsyncError::internal_deserialize(&mut map)?),
_ => GetTranscriptAsyncCheckResult::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["in_progress",
"complete",
"failed",
"other"];
deserializer.deserialize_struct("GetTranscriptAsyncCheckResult", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for GetTranscriptAsyncCheckResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match self {
GetTranscriptAsyncCheckResult::InProgress => {
let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 1)?;
s.serialize_field(".tag", "in_progress")?;
s.end()
}
GetTranscriptAsyncCheckResult::Complete(x) => {
let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
GetTranscriptAsyncCheckResult::Failed(x) => {
let mut s = serializer.serialize_struct("GetTranscriptAsyncCheckResult", 3)?;
s.serialize_field(".tag", "failed")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
GetTranscriptAsyncCheckResult::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct GetTranscriptAsyncError {
pub error_code: ErrorCode,
pub error_details: Option<ContentApiV2Error>,
}
impl Default for GetTranscriptAsyncError {
fn default() -> Self {
GetTranscriptAsyncError {
error_code: ErrorCode::UnknownError,
error_details: None,
}
}
}
impl GetTranscriptAsyncError {
pub fn with_error_code(mut self, value: ErrorCode) -> Self {
self.error_code = value;
self
}
pub fn with_error_details(mut self, value: ContentApiV2Error) -> Self {
self.error_details = Some(value);
self
}
}
const GET_TRANSCRIPT_ASYNC_ERROR_FIELDS: &[&str] = &["error_code",
"error_details"];
impl GetTranscriptAsyncError {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<GetTranscriptAsyncError, V::Error> {
let mut field_error_code = None;
let mut field_error_details = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"error_code" => {
if field_error_code.is_some() {
return Err(::serde::de::Error::duplicate_field("error_code"));
}
field_error_code = Some(map.next_value()?);
}
"error_details" => {
if field_error_details.is_some() {
return Err(::serde::de::Error::duplicate_field("error_details"));
}
field_error_details = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = GetTranscriptAsyncError {
error_code: field_error_code.unwrap_or(ErrorCode::UnknownError),
error_details: field_error_details.and_then(Option::flatten),
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if self.error_code != ErrorCode::UnknownError {
s.serialize_field("error_code", &self.error_code)?;
}
if let Some(val) = &self.error_details {
s.serialize_field("error_details", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptAsyncError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetTranscriptAsyncError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTranscriptAsyncError struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetTranscriptAsyncError::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetTranscriptAsyncError", GET_TRANSCRIPT_ASYNC_ERROR_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetTranscriptAsyncError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetTranscriptAsyncError", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive] pub struct GetTranscriptResult {
pub structured_transcript: Option<ApiStructuredTranscript>,
}
impl GetTranscriptResult {
pub fn with_structured_transcript(mut self, value: ApiStructuredTranscript) -> Self {
self.structured_transcript = Some(value);
self
}
}
const GET_TRANSCRIPT_RESULT_FIELDS: &[&str] = &["structured_transcript"];
impl GetTranscriptResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<GetTranscriptResult, V::Error> {
let mut field_structured_transcript = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"structured_transcript" => {
if field_structured_transcript.is_some() {
return Err(::serde::de::Error::duplicate_field("structured_transcript"));
}
field_structured_transcript = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = GetTranscriptResult {
structured_transcript: field_structured_transcript.and_then(Option::flatten),
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if let Some(val) = &self.structured_transcript {
s.serialize_field("structured_transcript", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetTranscriptResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetTranscriptResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTranscriptResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetTranscriptResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetTranscriptResult", GET_TRANSCRIPT_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetTranscriptResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetTranscriptResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive] pub struct MediaDurationError {
pub limit: i32,
}
impl MediaDurationError {
pub fn with_limit(mut self, value: i32) -> Self {
self.limit = value;
self
}
}
const MEDIA_DURATION_ERROR_FIELDS: &[&str] = &["limit"];
impl MediaDurationError {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<MediaDurationError, V::Error> {
let mut field_limit = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"limit" => {
if field_limit.is_some() {
return Err(::serde::de::Error::duplicate_field("limit"));
}
field_limit = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = MediaDurationError {
limit: field_limit.unwrap_or(0),
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if self.limit != 0 {
s.serialize_field("limit", &self.limit)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for MediaDurationError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = MediaDurationError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a MediaDurationError struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
MediaDurationError::internal_deserialize(map)
}
}
deserializer.deserialize_struct("MediaDurationError", MEDIA_DURATION_ERROR_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for MediaDurationError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("MediaDurationError", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum TimestampLevel {
Unknown,
Sentence,
Word,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for TimestampLevel {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = TimestampLevel;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a TimestampLevel structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"unknown" => TimestampLevel::Unknown,
"sentence" => TimestampLevel::Sentence,
"word" => TimestampLevel::Word,
_ => TimestampLevel::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["unknown",
"sentence",
"word",
"other"];
deserializer.deserialize_struct("TimestampLevel", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for TimestampLevel {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match self {
TimestampLevel::Unknown => {
let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
s.serialize_field(".tag", "unknown")?;
s.end()
}
TimestampLevel::Sentence => {
let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
s.serialize_field(".tag", "sentence")?;
s.end()
}
TimestampLevel::Word => {
let mut s = serializer.serialize_struct("TimestampLevel", 1)?;
s.serialize_field(".tag", "word")?;
s.end()
}
TimestampLevel::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}