use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use crate::subtitle::SubtitleStyle;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SubtitleConfig {
pub source: SubtitleSource,
pub format: SubtitleFormat,
pub style: Option<SubtitleStyle>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SubtitleSource {
File(PathBuf),
Inline(String),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SubtitleFormat {
Srt,
Vtt,
Ass,
}
impl SubtitleFormat {
pub fn extension(&self) -> &'static str {
match self {
Self::Srt => "srt",
Self::Vtt => "vtt",
Self::Ass => "ass",
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn subtitle_formats_report_extensions() {
assert_eq!(SubtitleFormat::Srt.extension(), "srt");
assert_eq!(SubtitleFormat::Vtt.extension(), "vtt");
assert_eq!(SubtitleFormat::Ass.extension(), "ass");
}
}