[−][src]Struct srtlib::Subtitle
A single subtitle.
Contains the numeric counter, the beginning and end timestamps and the text of the subtitle.
Examples
use srtlib::Subtitle; use srtlib::Timestamp; let sub = Subtitle::new(1, Timestamp::new(0, 0, 0, 0), Timestamp::new(0, 0, 1, 0), "Hello world".to_string()); assert_eq!(sub.to_string(), "1\n00:00:00,000 --> 00:00:01,000\nHello world"); let sub = Subtitle::parse("2\n00:00:01,500 --> 00:00:02,500\nFooBar".to_string()).unwrap(); assert_eq!(sub.text, "FooBar");
Fields
num: usize
start_time: Timestamp
end_time: Timestamp
text: String
Implementations
impl Subtitle
[src]
pub fn new(
num: usize,
start_time: Timestamp,
end_time: Timestamp,
text: String
) -> Subtitle
[src]
num: usize,
start_time: Timestamp,
end_time: Timestamp,
text: String
) -> Subtitle
Constructs a new Subtitle.
pub fn parse(input: String) -> Result<Subtitle, ParsingError>
[src]
Construct a new subtitle by parsing a string with the format "num\nstart --> end\ntext" where start and end are timestamps using the format hours:minutes:seconds,milliseconds.
Errors
If this function encounters anything unexpected while parsing the string, a corresponding error variant will be returned.
pub fn add_hours(&mut self, n: i32)
[src]
Moves the start and end timestamps n hours forward in time. Negative values may be provided in order to move the timestamps back in time.
Panics
Panics if we exceed the upper limit or go below zero.
pub fn add_minutes(&mut self, n: i32)
[src]
Moves the start and end timestamps n minutes forward in time. Negative values may be provided in order to move the timestamps back in time.
Panics
Panics if we exceed the upper limit or go below zero.
pub fn add_seconds(&mut self, n: i32)
[src]
Moves the start and end timestamps n seconds forward in time. Negative values may be provided in order to move the timestamps back in time.
Panics
Panics if we exceed the upper limit or go below zero.
pub fn add_milliseconds(&mut self, n: i32)
[src]
Moves the start and end timestamps n milliseconds forward in time. Negative values may be provided in order to move the timestamps back in time.
Panics
Panics if we exceed the upper limit or go below zero.
Trait Implementations
impl Debug for Subtitle
[src]
impl Display for Subtitle
[src]
impl Eq for Subtitle
[src]
impl Hash for Subtitle
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Subtitle
[src]
fn cmp(&self, other: &Subtitle) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Subtitle> for Subtitle
[src]
impl PartialOrd<Subtitle> for Subtitle
[src]
fn partial_cmp(&self, other: &Subtitle) -> Option<Ordering>
[src]
fn lt(&self, other: &Subtitle) -> bool
[src]
fn le(&self, other: &Subtitle) -> bool
[src]
fn gt(&self, other: &Subtitle) -> bool
[src]
fn ge(&self, other: &Subtitle) -> bool
[src]
impl StructuralEq for Subtitle
[src]
impl StructuralPartialEq for Subtitle
[src]
Auto Trait Implementations
impl RefUnwindSafe for Subtitle
impl Send for Subtitle
impl Sync for Subtitle
impl Unpin for Subtitle
impl UnwindSafe for Subtitle
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,