Skip to main content

TimecodeGenerator

Struct TimecodeGenerator 

Source
pub struct TimecodeGenerator {
    pub running: bool,
    /* private fields */
}
Expand description

A free-running timecode generator.

The generator owns a current position expressed as a Timecode and advances it one frame at a time each time next is called. The generator can be paused (running = false), reset to an arbitrary position, seeked, and fast-forwarded/rewound by an arbitrary number of frames.

Fields§

§running: bool

Whether the generator is advancing on each call to next.

Implementations§

Source§

impl TimecodeGenerator

Source

pub fn new(start: Timecode) -> Self

Create a new generator starting at start with the given frame_rate.

The generator starts in the running state.

§Errors

Forwards any error from Timecode::new if start describes an invalid timecode.

Source

pub fn at_midnight(frame_rate: FrameRate) -> Result<Self, TimecodeError>

Create a generator starting at midnight (00:00:00:00) for the given frame rate.

§Errors

Returns an error if frame_rate cannot produce a valid midnight timecode (should never occur for well-defined frame rates).

Source

pub fn next(&mut self) -> Timecode

Advance the generator by one frame (if running) and return the timecode before the increment.

If running is false the current position is returned without advancing.

Midnight roll-over is handled transparently; the generator continues from 00:00:00:00 after 23:59:59:FF.

Source

pub fn peek(&self) -> Timecode

Return the current timecode position without advancing.

Source

pub fn reset(&mut self) -> Result<(), TimecodeError>

Reset the generator to midnight (00:00:00:00) for its current frame rate.

§Errors

Returns an error if building the midnight timecode fails.

Source

pub fn reset_to(&mut self, tc: Timecode)

Seek to (reset to) an arbitrary timecode.

The generator adopts the frame rate embedded in tc.

Source

pub fn seek(&mut self, tc: Timecode)

Seek to a specific timecode (alias of reset_to).

Source

pub fn skip_frames(&mut self, n: i64) -> Result<(), TimecodeError>

Skip forward (n > 0) or backward (n < 0) by n frames.

The operation wraps around midnight boundaries correctly using the modular arithmetic built into Timecode::from_frames.

§Errors

Returns an error if the resulting frame count cannot be converted back to a valid timecode.

Source

pub fn start(&mut self)

Start the generator (set running = true).

Source

pub fn stop(&mut self)

Stop the generator (set running = false).

Source

pub fn frame_rate(&self) -> FrameRate

Return the frame rate of the current timecode.

Trait Implementations§

Source§

impl Clone for TimecodeGenerator

Source§

fn clone(&self) -> TimecodeGenerator

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimecodeGenerator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.