SubtitleMetadata

Struct SubtitleMetadata 

Source
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 content
  • language: Language code (ISO 639-1/639-3) for the subtitle content
  • encoding: Character encoding used in the original file
  • frame_rate: Video frame rate for frame-based timing formats
  • original_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: String

Character 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: SubtitleFormatType

Original format type before any conversions.

Tracks the source format to maintain conversion history and format-specific feature compatibility.

Implementations§

Source§

impl SubtitleMetadata

Source

pub fn new(format: SubtitleFormatType) -> Self

Create new metadata with default values and specified format.

§Arguments
  • format - The original format type
§Examples
let metadata = SubtitleMetadata::new(SubtitleFormatType::Srt);
assert_eq!(metadata.encoding, "UTF-8");
Source

pub fn is_frame_based(&self) -> bool

Check if the subtitle uses frame-based timing.

Returns true if the format requires frame rate information.

Source

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.

Source

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

Source§

fn clone(&self) -> SubtitleMetadata

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SubtitleMetadata

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SubtitleMetadata

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,