pub struct SubtitleMetadata {
pub title: Option<String>,
pub language: Option<String>,
pub encoding: String,
pub frame_rate: Option<f32>,
pub original_format: SubtitleFormatType,
}Expand description
Metadata associated with a subtitle file, containing format and content information.
This structure holds descriptive information about the subtitle file that may be embedded in the file format or derived during processing. It helps maintain context during format conversions and provides useful information for subtitle management.
§Fields Description
title: Optional title of the media or subtitle contentlanguage: Language code (ISO 639-1/639-3) for the subtitle contentencoding: Character encoding used in the original fileframe_rate: Video frame rate for frame-based timing formatsoriginal_format: The source format before any conversions
§Examples
use subx_cli::core::formats::{SubtitleMetadata, SubtitleFormatType};
let metadata = SubtitleMetadata {
title: Some("Episode 1".to_string()),
language: Some("en".to_string()),
encoding: "UTF-8".to_string(),
frame_rate: Some(23.976),
original_format: SubtitleFormatType::Srt,
};
assert!(metadata.is_frame_based());
assert_eq!(metadata.display_name(), "Episode 1 (English)");Fields§
§title: Option<String>Optional title of the subtitle content or associated media.
This may be extracted from the subtitle file header or derived from the filename. Used for display and organization purposes.
language: Option<String>Language code for the subtitle content.
Uses ISO 639-1 (2-letter) or ISO 639-3 (3-letter) codes. Examples: “en”, “zh”, “ja”, “chi”, “eng”
encoding: StringCharacter encoding of the original subtitle file.
Common values: “UTF-8”, “UTF-16”, “GB2312”, “BIG5”, “Shift_JIS” This information is crucial for proper text decoding.
frame_rate: Option<f32>Video frame rate for frame-based timing calculations.
Required for SUB format and useful for timing validation. Common values: 23.976, 24.0, 25.0, 29.97, 30.0
original_format: SubtitleFormatTypeOriginal format type before any conversions.
Tracks the source format to maintain conversion history and format-specific feature compatibility.
Implementations§
Source§impl SubtitleMetadata
impl SubtitleMetadata
Sourcepub fn new(format: SubtitleFormatType) -> Self
pub fn new(format: SubtitleFormatType) -> Self
Sourcepub fn is_frame_based(&self) -> bool
pub fn is_frame_based(&self) -> bool
Check if the subtitle uses frame-based timing.
Returns true if the format requires frame rate information.
Sourcepub fn display_name(&self) -> String
pub fn display_name(&self) -> String
Generate a display-friendly name for the subtitle.
Combines title and language information for user presentation.
§Returns
A formatted string like “Title (Language)” or just “Language” if no title.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if the metadata contains complete information.
Returns true if title, language, and frame rate (when needed) are set.
Trait Implementations§
Source§impl Clone for SubtitleMetadata
impl Clone for SubtitleMetadata
Source§fn clone(&self) -> SubtitleMetadata
fn clone(&self) -> SubtitleMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more