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>
impl<'a> Subtitle<'a>
Sourcepub fn blocks(&self) -> &'a [TtiBlock]
pub fn blocks(&self) -> &'a [TtiBlock]
All TTI blocks of the subtitle, including user data blocks, in file order.
Sourcepub fn subtitle_number(&self) -> u16
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());Sourcepub fn header_block(&self) -> &'a TtiBlock
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));
}Sourcepub fn is_comment(&self) -> bool
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());Sourcepub fn text_blocks(&self) -> impl Iterator<Item = &'a TtiBlock> + use<'a>
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.
Sourcepub fn user_data_blocks(&self) -> impl Iterator<Item = &'a TtiBlock> + use<'a>
pub fn user_data_blocks(&self) -> impl Iterator<Item = &'a TtiBlock> + use<'a>
The user data blocks (EBN FEh) of the subtitle.
Sourcepub fn text(&self) -> String
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());Sourcepub fn text_elements(&self) -> Vec<TextElement>
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);