example2/
example2.rs

1extern crate subparse;
2
3use subparse::timetypes::{TimePoint, TimeSpan};
4use subparse::{SrtFile, SubtitleFileInterface};
5
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}