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 moreSource§impl Debug for SubtitleMetadata
impl Debug for SubtitleMetadata
Auto Trait Implementations§
impl Freeze for SubtitleMetadata
impl RefUnwindSafe for SubtitleMetadata
impl Send for SubtitleMetadata
impl Sync for SubtitleMetadata
impl Unpin for SubtitleMetadata
impl UnwindSafe for SubtitleMetadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.