Skip to main content

ass_editor/formats/webvtt/
format.rs

1//! `WebVttFormat` handler definition and trait dispatch wiring.
2//!
3//! Defines the [`WebVttFormat`] type, its constructor, and the [`Format`]
4//! dispatch implementation. Import and export behaviour live in sibling
5//! modules.
6
7use crate::formats::{Format, FormatExporter, FormatImporter, FormatInfo};
8
9/// WebVTT format handler with style and positioning preservation
10#[derive(Debug)]
11pub struct WebVttFormat {
12    pub(super) info: FormatInfo,
13}
14
15impl WebVttFormat {
16    /// Create a new WebVTT format handler
17    pub fn new() -> Self {
18        Self {
19            info: FormatInfo {
20                name: "WebVTT".to_string(),
21                extensions: vec!["vtt".to_string(), "webvtt".to_string()],
22                mime_type: "text/vtt".to_string(),
23                description: "WebVTT subtitle format with full style and positioning preservation"
24                    .to_string(),
25                supports_styling: true,
26                supports_positioning: true,
27            },
28        }
29    }
30}
31
32impl Default for WebVttFormat {
33    fn default() -> Self {
34        Self::new()
35    }
36}
37
38impl Format for WebVttFormat {
39    fn as_importer(&self) -> &dyn FormatImporter {
40        self
41    }
42
43    fn as_exporter(&self) -> &dyn FormatExporter {
44        self
45    }
46}