pub struct VTTFile {
pub styles: Vec<VTTStyle>,
pub lines: Vec<VTTLine>,
}
Fields§
§styles: Vec<VTTStyle>
§lines: Vec<VTTLine>
Implementations§
source§impl VTTFile
impl VTTFile
sourcepub fn to_file(self, path: &str) -> Result<()>
pub fn to_file(self, path: &str) -> Result<()>
Takes the path of the file in the form of a String to be written to as input.
Examples found in repository?
examples/simplest_usage.rs (line 15)
5 6 7 8 9 10 11 12 13 14 15 16
fn main() {
let mut sub: VTTFile = Subtitle::from_str("tests/fixtures/test.srt")
.unwrap()
.into();
for style in sub.styles.iter_mut() {
style.color = rsubs_lib::util::color::ColorType::VTTColor0A(rsubs_lib::util::color::RED);
}
for line in sub.lines.iter_mut() {
line.line_text = line.line_text.clone() + "!!!!!!";
}
sub.to_file("result.vtt").unwrap();
}
More examples
examples/convert_around.rs (line 10)
7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() {
vtt::VTTFile::from(srt::SRTFile::from_str("./tests/fixtures/test.srt").unwrap()) // Can read either a file or a string
// converts file to WEBVTT
.to_file("./tests/fixtures/ex_test_1.vtt") // Writes the converted subtitle to a file
.unwrap();
ssa::SSAFile::from(vtt::parse("./tests/fixtures/test.vtt".to_string()).unwrap()) // converts file to SSA/ASS
.to_file("./tests/fixtures/ex_test_1.ass")
.unwrap();
srt::SRTFile::from(ssa::parse("./tests/fixtures/test.ass".to_string()).unwrap())
// converts file to SRT
.to_file("./tests/fixtures/ex_test_1.srt")
.unwrap();
}
Trait Implementations§
source§impl<'de> Deserialize<'de> for VTTFile
impl<'de> Deserialize<'de> for VTTFile
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for VTTFile
impl PartialEq for VTTFile
impl Eq for VTTFile
impl StructuralEq for VTTFile
impl StructuralPartialEq for VTTFile
Auto Trait Implementations§
impl RefUnwindSafe for VTTFile
impl Send for VTTFile
impl Sync for VTTFile
impl Unpin for VTTFile
impl UnwindSafe for VTTFile
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