use serde::{Deserialize, Serialize};
use validator::Validate;
#[derive(Debug, Clone, Serialize, Validate)]
pub struct VoiceListQuery {
#[serde(skip_serializing_if = "Option::is_none")]
pub voice_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub voice_type: Option<VoiceType>,
}
impl Default for VoiceListQuery {
fn default() -> Self {
Self::new()
}
}
impl VoiceListQuery {
pub fn new() -> Self {
Self {
voice_name: None,
voice_type: None,
}
}
pub fn with_voice_name(mut self, name: impl Into<String>) -> Self {
self.voice_name = Some(name.into());
self
}
pub fn with_voice_type(mut self, vt: VoiceType) -> Self {
self.voice_type = Some(vt);
self
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum VoiceType {
Official,
Private,
}
impl VoiceType {
pub fn as_str(&self) -> &'static str {
match self {
VoiceType::Official => "OFFICIAL",
VoiceType::Private => "PRIVATE",
}
}
}