pub struct Timecode { /* private fields */ }Expand description
A SMPTE timecode value.
Internally stored as a validated tuple (hh, mm, ss, ff).
Drop-frame flag determines the string representation and frame counting.
Implementations§
Source§impl Timecode
impl Timecode
Sourcepub fn new(
hours: u8,
minutes: u8,
seconds: u8,
frames: u8,
rate: FrameRate,
drop_frame: bool,
) -> Result<Self, TimecodeError>
pub fn new( hours: u8, minutes: u8, seconds: u8, frames: u8, rate: FrameRate, drop_frame: bool, ) -> Result<Self, TimecodeError>
Construct a timecode from components.
§Errors
Returns TimecodeError if any component is out of range.
Sourcepub fn is_drop_frame(&self) -> bool
pub fn is_drop_frame(&self) -> bool
Whether this is a drop-frame timecode.
Sourcepub fn to_frame_count(self) -> u64
pub fn to_frame_count(self) -> u64
Convert to an absolute frame count (from 00:00:00:00).
Uses the standard SMPTE drop-frame algorithm for DF timecodes.
Sourcepub fn from_frame_count(
total: u64,
rate: FrameRate,
drop_frame: bool,
) -> Result<Self, TimecodeError>
pub fn from_frame_count( total: u64, rate: FrameRate, drop_frame: bool, ) -> Result<Self, TimecodeError>
Construct from an absolute frame count.
§Errors
Returns an error if the resulting components are invalid.
Sourcepub fn to_secs_f64(self) -> f64
pub fn to_secs_f64(self) -> f64
Convert to real-time seconds from 00:00:00:00.
Sourcepub fn from_secs_f64(
secs: f64,
rate: FrameRate,
drop_frame: bool,
) -> Result<Self, TimecodeError>
pub fn from_secs_f64( secs: f64, rate: FrameRate, drop_frame: bool, ) -> Result<Self, TimecodeError>
Sourcepub fn add_frames(self, frames: i64) -> Result<Self, TimecodeError>
pub fn add_frames(self, frames: i64) -> Result<Self, TimecodeError>
Sourcepub fn diff_frames(self, other: Self) -> Option<i64>
pub fn diff_frames(self, other: Self) -> Option<i64>
Compute the signed frame-count difference (self - other).
Returns None if the rates differ.
Sourcepub fn parse(s: &str, rate: FrameRate) -> Result<Self, TimecodeError>
pub fn parse(s: &str, rate: FrameRate) -> Result<Self, TimecodeError>
Parse a SMPTE timecode string.
Accepts HH:MM:SS:FF (NDF) and HH:MM:SS;FF (DF).
§Errors
Returns a TimecodeError if the string is malformed.
Trait Implementations§
impl Copy for Timecode
Source§impl<'de> Deserialize<'de> for Timecode
impl<'de> Deserialize<'de> for Timecode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Timecode
impl StructuralPartialEq for Timecode
Auto Trait Implementations§
impl Freeze for Timecode
impl RefUnwindSafe for Timecode
impl Send for Timecode
impl Sync for Timecode
impl Unpin for Timecode
impl UnsafeUnpin for Timecode
impl UnwindSafe for Timecode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more