pub struct VttFormat;Expand description
Subtitle format implementation for WebVTT.
The VttFormat struct implements parsing, serialization, and
detection for WebVTT files. See the parser module documentation
for the malformed-input disposition matrix observed by
VttFormat::parse.
Trait Implementations§
Source§impl SubtitleFormat for VttFormat
impl SubtitleFormat for VttFormat
Source§fn parse(&self, content: &str) -> Result<Subtitle>
fn parse(&self, content: &str) -> Result<Subtitle>
Parse WebVTT content.
§Malformed-input dispositions
- Empty input → returns
crate::error::SubXError::SubtitleFormat. - Missing
WEBVTTsignature → returnscrate::error::SubXError::SubtitleFormat. - Leading UTF-8 BOM with valid content → BOM is consumed and the
file is parsed normally. This parser-level strip is additive
to
crate::core::formats::encoding::converter’s file-layer strip; both layers coexist by design. - Leading UTF-8 BOM with otherwise invalid content → returns
crate::error::SubXError::SubtitleFormat(the post-BOMWEBVTTcheck fails). - Out-of-order cues → preserved in original file order; no implicit sort is performed.
- Cue marker line with a negative timestamp → that block is
skipped, a
debug!log records the skip, and parsing continues. - Cue body exceeding the per-cue cap (1 MiB) → returns
crate::error::SubXError::SubtitleFormat. The cap is enforced on raw pre-normalization bytes, so\r\npadding cannot bypass the limit by shrinking under line-ending normalization. - CRLF (
\r\n), bare-CR (\r), or mixed line endings → input is normalized to LF after theWEBVTTheader check and before block splitting; CRLF and mixed inputs parse to the same entry count and text content as their LF counterpart. - Final cue not followed by a trailing blank line → still recognized; the file parses successfully.
Source§fn serialize(&self, subtitle: &Subtitle) -> Result<String>
fn serialize(&self, subtitle: &Subtitle) -> Result<String>
Serialize a
Subtitle structure into format-specific text representation. Read moreSource§fn detect(&self, content: &str) -> bool
fn detect(&self, content: &str) -> bool
Detect whether the provided content matches this subtitle format. Read more
Source§fn format_name(&self) -> &'static str
fn format_name(&self) -> &'static str
Returns the human-readable name of this subtitle format. Read more
Source§fn file_extensions(&self) -> &'static [&'static str]
fn file_extensions(&self) -> &'static [&'static str]
Returns the list of supported file extensions for this format. Read more
Source§fn supports_styling(&self) -> bool
fn supports_styling(&self) -> bool
Check if this format supports advanced styling features. Read more
Source§fn uses_frame_timing(&self) -> bool
fn uses_frame_timing(&self) -> bool
Check if this format uses frame-based timing. Read more
Auto Trait Implementations§
impl Freeze for VttFormat
impl RefUnwindSafe for VttFormat
impl Send for VttFormat
impl Sync for VttFormat
impl Unpin for VttFormat
impl UnsafeUnpin for VttFormat
impl UnwindSafe for VttFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more