pub struct SrtFile { /* private fields */ }
Expand description
Represents a .srt
file.
Implementations§
Source§impl SrtFile
impl SrtFile
Sourcepub fn parse(s: &str) -> SubtitleParserResult<SrtFile>
pub fn parse(s: &str) -> SubtitleParserResult<SrtFile>
Parse a .srt
subtitle string to SrtFile
.
Source§impl SrtFile
impl SrtFile
Sourcepub fn create(v: Vec<(TimeSpan, String)>) -> SubtitleParserResult<SrtFile>
pub fn create(v: Vec<(TimeSpan, String)>) -> SubtitleParserResult<SrtFile>
Creates .srt file from scratch.
Examples found in repository?
examples/example2.rs (line 18)
6fn main() {
7 // example how to create a fresh .srt file
8 let lines = vec![
9 (
10 TimeSpan::new(TimePoint::from_msecs(1500), TimePoint::from_msecs(3700)),
11 "line1".to_string(),
12 ),
13 (
14 TimeSpan::new(TimePoint::from_msecs(4500), TimePoint::from_msecs(8700)),
15 "line2".to_string(),
16 ),
17 ];
18 let file = SrtFile::create(lines).unwrap();
19
20 // generate file content
21 let srt_string = String::from_utf8(file.to_data().unwrap()).unwrap();
22 println!("{}", srt_string);
23}
Trait Implementations§
Source§impl From<SrtFile> for SubtitleFile
impl From<SrtFile> for SubtitleFile
Source§fn from(f: SrtFile) -> SubtitleFile
fn from(f: SrtFile) -> SubtitleFile
Converts to this type from the input type.
Source§impl SubtitleFileInterface for SrtFile
impl SubtitleFileInterface for SrtFile
Source§fn get_subtitle_entries(&self) -> SubtitleParserResult<Vec<SubtitleEntry>>
fn get_subtitle_entries(&self) -> SubtitleParserResult<Vec<SubtitleEntry>>
The subtitle entries can be changed by calling
update_subtitle_entries()
.Source§fn update_subtitle_entries(
&mut self,
new_subtitle_entries: &[SubtitleEntry],
) -> SubtitleParserResult<()>
fn update_subtitle_entries( &mut self, new_subtitle_entries: &[SubtitleEntry], ) -> SubtitleParserResult<()>
Set the entries from the subtitle entries from the
get_subtitle_entries()
. Read moreAuto Trait Implementations§
impl Freeze for SrtFile
impl RefUnwindSafe for SrtFile
impl Send for SrtFile
impl Sync for SrtFile
impl Unpin for SrtFile
impl UnwindSafe for SrtFile
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
Mutably borrows from an owned value. Read more