Skip to main content

TcRange

Struct TcRange 

Source
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

Source

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.

Source

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.

Source

pub fn start_frames(&self) -> u64

Returns the start frame number (inclusive).

Source

pub fn end_frames(&self) -> u64

Returns the end frame number (exclusive).

Source

pub fn duration_frames(&self) -> u64

Returns the duration in frames.

Source

pub fn duration_seconds(&self) -> f64

Returns the duration in seconds.

Source

pub fn contains_frame(&self, frame: u64) -> bool

Checks whether the given frame number falls within this range.

Source

pub fn contains_timecode(&self, tc: &Timecode) -> bool

Checks whether the given timecode falls within this range.

Source

pub fn frame_rate_info(&self) -> FrameRateInfo

Returns the FrameRateInfo associated with this range.

Source

pub fn overlaps(&self, other: &Self) -> bool

Checks whether two ranges overlap.

Source

pub fn overlap_kind(&self, other: &Self) -> OverlapKind

Classifies the overlap between two ranges.

Source

pub fn intersect(&self, other: &Self) -> Option<Self>

Returns the intersection of two ranges, if any.

Source

pub fn union(&self, other: &Self) -> Option<Self>

Merges two ranges into one if they overlap or are adjacent.

Source

pub fn split_at_frame(&self, frame: u64) -> SplitResult

Splits the range at the given frame number.

Source

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.

Source

pub fn frame_iter(&self) -> impl Iterator<Item = u64>

Returns a list of frame numbers in this range.

Source

pub fn extend(&self, head_frames: u64, tail_frames: u64) -> Self

Extends the range by the given number of frames on each side.

Source

pub fn trim(&self, head_frames: u64, tail_frames: u64) -> Option<Self>

Trims the range by the given number of frames on each side.

Returns None if the range would become empty.

Trait Implementations§

Source§

impl Clone for TcRange

Source§

fn clone(&self) -> TcRange

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TcRange

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for TcRange

Source§

impl PartialEq for TcRange

Source§

fn eq(&self, other: &TcRange) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TcRange

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.