Struct video_timecode::Timecode [] [src]

pub struct Timecode<FrameRate> {
    pub frame_number: u32,
    pub hour: u8,
    pub minute: u8,
    pub second: u8,
    pub frame: u8,
    // some fields omitted
}

Representation of a timecode

Note: Currently the user-facing values are open properties. These may be replaced by getters to facilitate lazy evaluation.

Example

use video_timecode::*;

let timecode = match Timecode::<FrameRate24>::new(0, 0, 0, 10) {
    Ok(tc) => tc,
    _ => panic!()
};
assert_eq!(timecode.frame_number, 10);

let timecode = match Timecode::<FrameRate24>::new(0, 0, 10, 0) {
    Ok(tc) => tc,
    _ => panic!()
};
assert_eq!(timecode.frame_number, 240);

let timecode = Timecode::<FrameRate24>::from(240);
assert_eq!(timecode.hour, 0);
assert_eq!(timecode.minute, 0);
assert_eq!(timecode.second, 10);
assert_eq!(timecode.frame, 0);
assert_eq!(timecode.frame_number, 240);

Fields

Frame number. The count of frames after 00:00:00:00

Methods

impl<T> Timecode<T>
[src]

[src]

Returns a timecode with the given hour/minute/second/frame fields.

Example

use video_timecode::*;

let timecode = match Timecode::<FrameRate24>::new(10, 0, 0, 0) {
    Ok(tc) => tc,
    _ => panic!()
};

assert_eq!(timecode.frame_number, 864000);

Trait Implementations

impl<FrameRate: Debug> Debug for Timecode<FrameRate>
[src]

[src]

Formats the value using the given formatter.

impl<FrameRate: PartialEq> PartialEq for Timecode<FrameRate>
[src]

[src]

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

[src]

This method tests for !=.

impl<T> FromStr for Timecode<T> where
    T: FrameRate
[src]

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more

impl<T> From<usize> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<usize> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<usize> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> From<u8> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<u8> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<u8> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> From<u16> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<u16> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<u16> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> From<u32> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<u32> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<u32> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> From<u64> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<u64> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<u64> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> From<isize> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<isize> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<isize> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> From<i8> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<i8> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<i8> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> From<i16> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<i16> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<i16> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> From<i32> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<i32> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<i32> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> From<i64> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the conversion.

impl<T> Add<i64> for Timecode<T> where
    T: FrameRate
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T> AddAssign<i64> for Timecode<T> where
    T: FrameRate
[src]

[src]

Performs the += operation.

impl<T> Add for Timecode<T> where
    T: FrameRate
[src]

Adding timecodes of different framerates together is not supported.

Since adding Timecodes of different frame rates together normally does not make any sense, it is better that the programmer has to mark this, by explicitly adding the number of frames.

Example

use video_timecode::*;

let tc1 = Timecode::<FrameRate2997>::new(0, 0, 0, 0).unwrap();
let tc2 = Timecode::<FrameRate24>::new(0, 0, 10, 0).unwrap();
let tc3 = tc1 + tc2.frame_number;

assert_eq!(tc3, Timecode::<FrameRate2997>::new(0, 0, 8, 0).unwrap());

The resulting type after applying the + operator.

[src]

Performs the + operation.