use crate::Result;
use crate::core::formats::{Subtitle, SubtitleFormat};
mod parser;
mod serializer;
mod time;
#[cfg(test)]
mod tests;
#[derive(Debug, Clone)]
pub struct AssStyle {
pub name: String,
pub font_name: String,
pub font_size: u32,
pub primary_color: Color,
pub secondary_color: Color,
pub outline_color: Color,
pub shadow_color: Color,
pub bold: bool,
pub italic: bool,
pub underline: bool,
pub alignment: i32,
}
#[derive(Debug, Clone)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
}
impl Color {
pub fn white() -> Self {
Color {
r: 255,
g: 255,
b: 255,
}
}
pub fn black() -> Self {
Color { r: 0, g: 0, b: 0 }
}
pub fn red() -> Self {
Color { r: 255, g: 0, b: 0 }
}
}
pub struct AssFormat;
impl SubtitleFormat for AssFormat {
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 {
content.contains("[Script Info]") || content.contains("Dialogue:")
}
fn format_name(&self) -> &'static str {
"ASS"
}
fn file_extensions(&self) -> &'static [&'static str] {
&["ass", "ssa"]
}
}