pub struct TtiBlock { /* private fields */ }Expand description
Text and Timing Information (TTI) block, 128 bytes with the text and timing of a subtitle.
Implementations§
Source§impl TtiBlock
impl TtiBlock
Sourcepub fn subtitle_group_number(&self) -> u8
pub fn subtitle_group_number(&self) -> u8
Subtitle Group Number (SGN).
Sourcepub fn subtitle_number(&self) -> u16
pub fn subtitle_number(&self) -> u16
Subtitle Number (SN).
Sourcepub fn extension_block_number(&self) -> u8
pub fn extension_block_number(&self) -> u8
Extension Block Number (EBN), see also TtiBlock::is_last_block and
TtiBlock::is_user_data.
Sourcepub fn cumulative_status(&self) -> &CumulativeStatus
pub fn cumulative_status(&self) -> &CumulativeStatus
Cumulative Status (CS).
Sourcepub fn time_code_in(
&self,
dfc: &DiskFormatCode,
) -> Result<Time, InvalidFieldValue<Time>>
pub fn time_code_in( &self, dfc: &DiskFormatCode, ) -> Result<Time, InvalidFieldValue<Time>>
Time Code In (TCI), validated against the ranges in the spec: hours 0-23, minutes and seconds 0-59 and frames according to the Disk Format Code.
On error, InvalidFieldValue::value gives the value as stored in the file.
§Example
use ebustl_parser::Time;
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
let dfc = stl.gsi.disk_format_code();
let time = Time { hours: 10, minutes: 0, seconds: 0, frames: 0 };
assert_eq!(Ok(time), stl.ttis[0].time_code_in(dfc));Sourcepub fn time_code_out(
&self,
dfc: &DiskFormatCode,
) -> Result<Time, InvalidFieldValue<Time>>
pub fn time_code_out( &self, dfc: &DiskFormatCode, ) -> Result<Time, InvalidFieldValue<Time>>
Time Code Out (TCO), validated against the ranges in the spec: hours 0-23, minutes and seconds 0-59 and frames according to the Disk Format Code.
On error, InvalidFieldValue::value gives the value as stored in the file.
§Example
use ebustl_parser::Time;
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
let dfc = stl.gsi.disk_format_code();
let time = Time { hours: 10, minutes: 0, seconds: 0, frames: 5 };
assert_eq!(Ok(time), stl.ttis[0].time_code_out(dfc));Sourcepub fn vertical_position(&self) -> u8
pub fn vertical_position(&self) -> u8
Vertical Position (VP), the row of the first subtitle row: 1-23 for teletext and 0 up to MNR for open subtitles.
Sourcepub fn justification(&self) -> Result<Justification, InvalidFieldValue<u8>>
pub fn justification(&self) -> Result<Justification, InvalidFieldValue<u8>>
Justification Code (JC), validated as 00h-03h.
On error, InvalidFieldValue::value gives the value as stored in the file.
§Example
use ebustl_parser::Justification;
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
assert_eq!(Ok(Justification::Centered), stl.ttis[0].justification());Sourcepub fn comment_flag(&self) -> Result<bool, InvalidFieldValue<u8>>
pub fn comment_flag(&self) -> Result<bool, InvalidFieldValue<u8>>
Comment Flag (CF), validated as 00h or 01h. true if the Text Field contains
comments not intended for transmission.
On error, InvalidFieldValue::value gives the value as stored in the file.
§Example
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
assert_eq!(Ok(false), stl.ttis[0].comment_flag());Source§impl TtiBlock
impl TtiBlock
Sourcepub fn new(
idx: u16,
tci: Time,
tco: Time,
txt: &str,
opt: TtiFormat,
cct: CharacterCodeTable,
) -> TtiBlock
pub fn new( idx: u16, tci: Time, tco: Time, txt: &str, opt: TtiFormat, cct: CharacterCodeTable, ) -> TtiBlock
Creates a teletext subtitle in a single TTI block (EBN FFh), with idx as Subtitle
Number.
Rows are separated by \n or \r\n. Text that does not fit in one block is
truncated, use Stl::add_sub to continue it in extension blocks.
§Example
use ebustl_parser::{CharacterCodeTable, Time, TtiBlock, TtiFormat};
let time = |seconds| Time { hours: 10, minutes: 0, seconds, frames: 0 };
let format = TtiFormat { jc: 2, vp: 20, dh: false };
let tti = TtiBlock::new(1, time(1), time(3), "One\nTwo", format, CharacterCodeTable::Latin);
assert_eq!("One\r\nTwo", tti.text());
assert!(tti.is_last_block());Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Decodes the Text Field of this single block into a string.
Control codes are dropped, except CR/LF which becomes \r\n. Use
TtiBlock::text_elements to get the control codes too.
A subtitle may span several blocks (extension blocks), use
Stl::subtitles and
Subtitle::text to get the complete text of a subtitle.
Sourcepub fn text_elements(&self) -> Vec<TextElement>
pub fn text_elements(&self) -> Vec<TextElement>
Decodes the Text Field of this single block into characters and control codes, e.g. teletext colors, double height and boxing, or italics for open subtitles.
A subtitle may span several blocks (extension blocks), use
Subtitle::text_elements to get the elements of the
complete subtitle.
§Example
use ebustl_parser::{TeletextControl, TextElement};
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
let elements = stl.ttis[2].text_elements();
assert_eq!(TextElement::Teletext(TeletextControl::DoubleHeight), elements[0]);Sourcepub fn is_user_data(&self) -> bool
pub fn is_user_data(&self) -> bool
Returns true for a block carrying user data (EBN FEh). Its Text Field is not
subtitle text and must not affect the rest of the subtitle.
§Example
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
assert!(!stl.ttis[0].is_user_data());Sourcepub fn is_text_block(&self) -> bool
pub fn is_text_block(&self) -> bool
Returns true if the Text Field of this block is part of the subtitle text, i.e. the
block is an extension block (EBN 00h-EFh) or the last block of a subtitle (EBN FFh).
User data (FEh) and blocks reserved for future use (F0h-FDh) are not.
§Example
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
assert!(stl.ttis.iter().all(|tti| tti.is_text_block()));Sourcepub fn is_last_block(&self) -> bool
pub fn is_last_block(&self) -> bool
Returns true for the last block of a subtitle (EBN FFh).
§Example
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
assert!(stl.ttis[0].is_last_block());Sourcepub fn is_comment(&self) -> bool
pub fn is_comment(&self) -> bool
Returns true if the Comment Flag (CF 01h) marks the Text Field as comments, which
are not intended for transmission.
§Example
let stl = ebustl_parser::parse_stl_from_file("stls/test.stl").unwrap();
assert!(!stl.ttis[0].is_comment());