use crate::Result;
use crate::core::formats::{Subtitle, SubtitleFormat};
use regex::Regex;
mod parser;
mod serializer;
mod time;
#[cfg(test)]
mod tests;
pub struct SrtFormat;
impl SubtitleFormat for SrtFormat {
fn parse(&self, content: &str) -> Result<Subtitle> {
parser::parse(content)
}
fn serialize(&self, subtitle: &Subtitle) -> Result<String> {
serializer::serialize(subtitle)
}
fn detect(&self, content: &str) -> bool {
let time_pattern =
Regex::new(r"\d{2}:\d{2}:\d{2},\d{3} --> \d{2}:\d{2}:\d{2},\d{3}").unwrap();
time_pattern.is_match(content)
}
fn format_name(&self) -> &'static str {
"SRT"
}
fn file_extensions(&self) -> &'static [&'static str] {
&["srt"]
}
}