use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct PcmAudioFormat {
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<Type>,
#[serde(rename = "rate", skip_serializing_if = "Option::is_none")]
pub rate: Option<Rate>,
}
impl PcmAudioFormat {
pub fn new() -> PcmAudioFormat {
PcmAudioFormat {
r#type: None,
rate: None,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "audio/pcm")]
AudioSlashPcm,
}
impl Default for Type {
fn default() -> Type {
Self::AudioSlashPcm
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Rate {
#[serde(rename = "24000")]
Variant24000,
}
impl Default for Rate {
fn default() -> Rate {
Self::Variant24000
}
}
impl std::fmt::Display for PcmAudioFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}