pub struct TcRange { /* private fields */ }Expand description
A contiguous range of timecodes defined by an inclusive start and exclusive end.
The range is measured in absolute frame counts for a given frame rate.
Implementations§
Source§impl TcRange
impl TcRange
Sourcepub fn new(start: &Timecode, end: &Timecode) -> Result<Self, TimecodeError>
pub fn new(start: &Timecode, end: &Timecode) -> Result<Self, TimecodeError>
Creates a new timecode range from two timecodes.
§Errors
Returns TimecodeError::InvalidConfiguration if start >= end or frame rate info differs.
Sourcepub fn from_frames(
start: u64,
end: u64,
fps: u8,
drop_frame: bool,
) -> Result<Self, TimecodeError>
pub fn from_frames( start: u64, end: u64, fps: u8, drop_frame: bool, ) -> Result<Self, TimecodeError>
Creates a range from raw frame numbers.
§Errors
Returns TimecodeError::InvalidConfiguration if start >= end.
Sourcepub fn start_frames(&self) -> u64
pub fn start_frames(&self) -> u64
Returns the start frame number (inclusive).
Sourcepub fn end_frames(&self) -> u64
pub fn end_frames(&self) -> u64
Returns the end frame number (exclusive).
Sourcepub fn duration_frames(&self) -> u64
pub fn duration_frames(&self) -> u64
Returns the duration in frames.
Sourcepub fn duration_seconds(&self) -> f64
pub fn duration_seconds(&self) -> f64
Returns the duration in seconds.
Sourcepub fn contains_frame(&self, frame: u64) -> bool
pub fn contains_frame(&self, frame: u64) -> bool
Checks whether the given frame number falls within this range.
Sourcepub fn contains_timecode(&self, tc: &Timecode) -> bool
pub fn contains_timecode(&self, tc: &Timecode) -> bool
Checks whether the given timecode falls within this range.
Sourcepub fn frame_rate_info(&self) -> FrameRateInfo
pub fn frame_rate_info(&self) -> FrameRateInfo
Returns the FrameRateInfo associated with this range.
Sourcepub fn overlap_kind(&self, other: &Self) -> OverlapKind
pub fn overlap_kind(&self, other: &Self) -> OverlapKind
Classifies the overlap between two ranges.
Sourcepub fn intersect(&self, other: &Self) -> Option<Self>
pub fn intersect(&self, other: &Self) -> Option<Self>
Returns the intersection of two ranges, if any.
Sourcepub fn union(&self, other: &Self) -> Option<Self>
pub fn union(&self, other: &Self) -> Option<Self>
Merges two ranges into one if they overlap or are adjacent.
Sourcepub fn split_at_frame(&self, frame: u64) -> SplitResult
pub fn split_at_frame(&self, frame: u64) -> SplitResult
Splits the range at the given frame number.
Sourcepub fn offset(&self, delta: i64) -> Result<Self, TimecodeError>
pub fn offset(&self, delta: i64) -> Result<Self, TimecodeError>
Offsets the range by a signed number of frames.
§Errors
Returns an error if the result would be negative.
Sourcepub fn frame_iter(&self) -> impl Iterator<Item = u64>
pub fn frame_iter(&self) -> impl Iterator<Item = u64>
Returns a list of frame numbers in this range.