pub struct TimecodeValue {
pub hh: u8,
pub mm: u8,
pub ss: u8,
pub ff: u8,
pub fps: f32,
pub drop_frame: bool,
}Expand description
A timecode value with arithmetic support.
Fields§
§hh: u8Hours component (0-23)
mm: u8Minutes component (0-59)
ss: u8Seconds component (0-59)
ff: u8Frames component (0 to fps-1)
fps: f32Frames per second (e.g. 25.0, 29.97, 30.0)
drop_frame: boolWhether this timecode uses drop-frame notation
Implementations§
Source§impl TimecodeValue
impl TimecodeValue
Sourcepub fn new(hh: u8, mm: u8, ss: u8, ff: u8, fps: f32, drop_frame: bool) -> Self
pub fn new(hh: u8, mm: u8, ss: u8, ff: u8, fps: f32, drop_frame: bool) -> Self
Create a new timecode value.
Sourcepub fn to_frame_count(&self) -> u64
pub fn to_frame_count(&self) -> u64
Convert to total frame count since 00:00:00:00.
For drop-frame timecode, applies the standard SMPTE drop-frame adjustment.
Sourcepub fn from_frame_count(frames: u64, fps: f32, drop_frame: bool) -> Self
pub fn from_frame_count(frames: u64, fps: f32, drop_frame: bool) -> Self
Create a timecode value from a frame count.
Sourcepub fn add_frames(&self, frames: i64) -> Self
pub fn add_frames(&self, frames: i64) -> Self
Add a number of frames (positive or negative), wrapping at 24 hours.
Sourcepub fn subtract(&self, other: &Self) -> i64
pub fn subtract(&self, other: &Self) -> i64
Compute the signed frame difference between self and another timecode.
Returns a positive value if self is later than other.
Sourcepub fn to_string_formatted(&self) -> String
pub fn to_string_formatted(&self) -> String
Convert to a formatted timecode string.
Uses colons for non-drop-frame and semicolons for drop-frame.
Trait Implementations§
Source§impl Clone for TimecodeValue
impl Clone for TimecodeValue
Source§fn clone(&self) -> TimecodeValue
fn clone(&self) -> TimecodeValue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TimecodeValue
impl Debug for TimecodeValue
Source§impl Display for TimecodeValue
impl Display for TimecodeValue
Source§impl PartialEq for TimecodeValue
impl PartialEq for TimecodeValue
impl Copy for TimecodeValue
impl StructuralPartialEq for TimecodeValue
Auto Trait Implementations§
impl Freeze for TimecodeValue
impl RefUnwindSafe for TimecodeValue
impl Send for TimecodeValue
impl Sync for TimecodeValue
impl Unpin for TimecodeValue
impl UnsafeUnpin for TimecodeValue
impl UnwindSafe for TimecodeValue
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
Mutably borrows from an owned value. Read more