pub struct Subtitle {
    pub num: usize,
    pub start_time: Timestamp,
    pub end_time: Timestamp,
    pub text: String,
}
Expand description

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: usizestart_time: Timestampend_time: Timestamptext: String

Implementations

Constructs a new Subtitle.

Construct a new subtitle by parsing a string with the format “num\nstart –> end\ntext” or the format “num\nstart –> end position_information\ntext” where start and end are timestamps using the format hours:minutes:seconds,milliseconds ; and position_information is position information of any format

Errors

If this function encounters anything unexpected while parsing the string, a corresponding error variant will be returned.

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.

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.

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.

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

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.