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: boolWhether the generator is advancing on each call to next.
Implementations§
Source§impl TimecodeGenerator
impl TimecodeGenerator
Sourcepub fn new(start: Timecode) -> Self
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.
Sourcepub fn at_midnight(frame_rate: FrameRate) -> Result<Self, TimecodeError>
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).
Sourcepub fn next(&mut self) -> Timecode
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.
Sourcepub fn reset(&mut self) -> Result<(), TimecodeError>
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.
Sourcepub fn reset_to(&mut self, tc: Timecode)
pub fn reset_to(&mut self, tc: Timecode)
Seek to (reset to) an arbitrary timecode.
The generator adopts the frame rate embedded in tc.
Sourcepub fn skip_frames(&mut self, n: i64) -> Result<(), TimecodeError>
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.
Sourcepub fn frame_rate(&self) -> FrameRate
pub fn frame_rate(&self) -> FrameRate
Return the frame rate of the current timecode.
Trait Implementations§
Source§impl Clone for TimecodeGenerator
impl Clone for TimecodeGenerator
Source§fn clone(&self) -> TimecodeGenerator
fn clone(&self) -> TimecodeGenerator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more