Skip to main content

Subtitle

Struct Subtitle 

Source
pub struct Subtitle<'a> { /* private fields */ }
Expand description

A subtitle made up of one or more consecutive TTI blocks.

Created by Stl::subtitles.

Implementations§

Source§

impl<'a> Subtitle<'a>

Source

pub fn blocks(&self) -> &'a [TtiBlock]

All TTI blocks of the subtitle, including user data blocks, in file order.

Source

pub fn subtitle_number(&self) -> u16

The Subtitle Number (SN) shared by all blocks of the subtitle.

§Example
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
let subtitle = stl.subtitles().next().unwrap();
assert_eq!(stl.ttis[0].subtitle_number(), subtitle.subtitle_number());
Source

pub fn header_block(&self) -> &'a TtiBlock

The block carrying the values valid for the whole subtitle: Subtitle Group Number, Cumulative Status, Time Code In/Out, Vertical Position, Justification Code and Comment Flag.

This is the first text block, or the first block if the subtitle only has user data or reserved blocks.

§Example
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
let dfc = stl.gsi.disk_format_code();
for subtitle in stl.subtitles() {
    let header = subtitle.header_block();
    println!("{:?} --> {:?}", header.time_code_in(dfc), header.time_code_out(dfc));
}
Source

pub fn is_comment(&self) -> bool

Returns true if the subtitle contains comments not intended for transmission (Comment Flag 01h in the header block).

§Example
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
assert_eq!(0, stl.subtitles().filter(|subtitle| subtitle.is_comment()).count());
Source

pub fn text_blocks(&self) -> impl Iterator<Item = &'a TtiBlock> + use<'a>

The blocks whose Text Field make up the subtitle text, in file order.

Source

pub fn user_data_blocks(&self) -> impl Iterator<Item = &'a TtiBlock> + use<'a>

The user data blocks (EBN FEh) of the subtitle.

Source

pub fn text(&self) -> String

Decodes the complete text of the subtitle.

The Text Fields of all text blocks are concatenated before decoding, so text and multi-byte characters may continue from one block to the next. User data and reserved blocks are skipped. See TtiBlock::text for how control codes are handled.

§Example
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
let subtitle = stl.subtitles().nth(11).unwrap();
assert_eq!("    dans la baie de New York.\r\n", subtitle.text());
Source

pub fn text_elements(&self) -> Vec<TextElement>

Decodes the complete subtitle into characters and control codes, e.g. teletext colors, double height and boxing, or italics for open subtitles.

The Text Fields are concatenated like for Subtitle::text.

§Example
use ebustl_parser::TextElement;

let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
let elements = stl.subtitles().nth(2).unwrap().text_elements();
let text: Vec<&str> = elements
    .iter()
    .filter_map(|element| match element {
        TextElement::Text(text) => Some(text.as_str()),
        _ => None,
    })
    .collect();
assert_eq!(vec!["au pied de la statue de la Liberté."], text);

Trait Implementations§

Source§

impl<'a> Clone for Subtitle<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Subtitle<'a>

Source§

impl<'a> Debug for Subtitle<'a>

Source§

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

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

impl<'a> Eq for Subtitle<'a>

Source§

impl<'a> PartialEq for Subtitle<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Subtitle<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Subtitle<'a>

§

impl<'a> RefUnwindSafe for Subtitle<'a>

§

impl<'a> Send for Subtitle<'a>

§

impl<'a> Sync for Subtitle<'a>

§

impl<'a> Unpin for Subtitle<'a>

§

impl<'a> UnsafeUnpin for Subtitle<'a>

§

impl<'a> UnwindSafe for Subtitle<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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, 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<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.