### TimeRange::start Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns the start as a Timestamp. ```APIDOC ## TimeRange::start ### Description Returns the start as a `Timestamp`. ### Returns - `Timestamp` - The start timestamp. ``` -------------------------------- ### TimeRange::with_start Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Sets the start PTS and returns a new TimeRange. ```APIDOC ## TimeRange::with_start ### Description Sets the start PTS and returns a new `TimeRange`. ### Parameters - **val** (i64) - The new start PTS value. ### Returns - `Self` - A new `TimeRange` with the updated start PTS. ``` -------------------------------- ### TimeRange::try_new Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Fallible variant of Self::new: returns None if end < start instead of panicking. Accepts start == end (degenerate instant range). ```APIDOC ## TimeRange::try_new ### Description Fallible variant of `Self::new`: returns `None` if `end < start` instead of panicking. Accepts `start == end` (degenerate instant range). ### Parameters - **start** (i64) - The starting point of the time range. - **end** (i64) - The ending point of the time range. - **timebase** (Timebase) - The timebase for the range. ### Returns - `Some(Self)` if `start <= end`. - `None` if `end < start`. ``` -------------------------------- ### TimeRange::set_start Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Sets the start PTS in place and returns a mutable reference to self. ```APIDOC ## TimeRange::set_start ### Description Sets the start PTS in place and returns a mutable reference to self. ### Parameters - **val** (i64) - The new start PTS value. ### Returns - `&mut Self` - A mutable reference to the `TimeRange`. ``` -------------------------------- ### Get try size hint for arbitrary Timebase generation Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Provides a size hint for the number of bytes required from `Unstructured` data to construct a Timebase, returning a Result. Available when the `arbitrary` crate feature is enabled. ```rust fn try_size_hint( depth: usize, ) -> Result<(usize, Option), MaxRecursionReached> ``` -------------------------------- ### Create TimeRange Safely Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html A fallible variant of `Self::new` that returns `None` if `end < start` instead of panicking. It accepts `start == end` for degenerate instant ranges. ```rust pub const fn try_new(start: i64, end: i64, timebase: Timebase) -> Option ``` -------------------------------- ### Create New TimeRange Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Creates a new TimeRange with the given start and end PTS values and a shared timebase. Panics if the end time is less than the start time. ```rust pub const fn new(start: i64, end: i64, timebase: Timebase) -> Self ``` -------------------------------- ### Modify TimeRange Start PTS Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Creates a new TimeRange with an updated start PTS value. Use `set_start` for in-place modification. ```rust pub const fn with_start(self, val: i64) -> Self ``` ```rust pub const fn set_start(&mut self, val: i64) -> &mut Self ``` -------------------------------- ### TimeRange::start_pts Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns the start PTS in the range’s timebase units. ```APIDOC ## TimeRange::start_pts ### Description Returns the start PTS in the range’s timebase units. ### Returns - `i64` - The start PTS. ``` -------------------------------- ### Get TimeRange Timestamps Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns the start and end points of the TimeRange as Timestamp objects. ```rust pub const fn start(&self) -> Timestamp ``` ```rust pub const fn end(&self) -> Timestamp ``` -------------------------------- ### TimeRange::new Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Creates a new TimeRange with the given start/end PTS and shared timebase. Panics if end < start. ```APIDOC ## TimeRange::new ### Description Creates a new `TimeRange` with the given start/end PTS and shared timebase. ### Parameters - **start** (i64) - The starting point of the time range. - **end** (i64) - The ending point of the time range. - **timebase** (Timebase) - The timebase for the range. ### Panics Panics if `end < start` (negative duration). ``` -------------------------------- ### Get size hint for arbitrary Timebase generation Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Provides a size hint for the number of bytes required from `Unstructured` data to construct a Timebase. Available when the `arbitrary` crate feature is enabled. ```rust fn size_hint(depth: usize) -> (usize, Option) ``` -------------------------------- ### Create Instant TimeRange Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Creates a degenerate (instant) range where both start and end are the same timestamp's PTS value. ```rust pub const fn instant(ts: Timestamp) -> Self ``` -------------------------------- ### TimeRange::duration Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns the elapsed Duration from start to end, or None if end is before start. ```APIDOC ## TimeRange::duration ### Description Returns the elapsed `Duration` from `start` to `end`, or `None` if `end` is before `start`. ### Returns - `Option` - The duration of the range, or `None` if invalid. ``` -------------------------------- ### Get Timebase numerator Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns the numerator of the Timebase. ```rust pub const fn num(&self) -> u32 ``` -------------------------------- ### TimeRange::is_instant Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns true if start == end (a degenerate instant range). ```APIDOC ## TimeRange::is_instant ### Description Returns `true` if `start == end` (a degenerate instant range). ### Returns - `bool` - `true` if the range is an instant, `false` otherwise. ``` -------------------------------- ### Calculate TimeRange Duration Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns the elapsed Duration from the start to the end of the TimeRange. Returns None if the end is before the start, though this should not occur with valid TimeRanges. ```rust pub const fn duration(&self) -> Duration ``` -------------------------------- ### TimeRange::instant Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Creates a degenerate (instant) range where start == end == ts.pts(). ```APIDOC ## TimeRange::instant ### Description Creates a degenerate (instant) range where `start == end == ts.pts()`. ### Parameters - **ts** (Timestamp) - The timestamp for the instant range. ``` -------------------------------- ### Get TimeRange PTS Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Retrieves the start and end PTS (Presentation Timestamp) values from the TimeRange in its native timebase units. ```rust pub const fn start_pts(&self) -> i64 ``` ```rust pub const fn end_pts(&self) -> i64 ``` -------------------------------- ### TimeRange::interpolate Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Linearly interpolates between start and end. ```APIDOC ## TimeRange::interpolate ### Description Linearly interpolates between `start` and `end`: `t = 0.0` returns `start`, `t = 1.0` returns `end`, `t = 0.5` the midpoint. `t` is clamped to `[0.0, 1.0]`. Rounds toward zero. Use this to map an old-style bias value `b ∈ [-1, 1]` onto the range: `range.interpolate((b + 1.0) * 0.5)`. ### Parameters - **t** (f64) - The interpolation factor, clamped to `[0.0, 1.0]`. ### Returns - `Timestamp` - The interpolated timestamp. ``` -------------------------------- ### Get PTS of Timestamp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Retrieves the presentation timestamp (PTS) value in the units of the timestamp's own timebase. To get a Duration, use `duration_since` or `rescale_to`. ```rust pub const fn pts(&self) -> i64 ``` -------------------------------- ### Get Timebase denominator Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns the non-zero denominator of the Timebase. ```rust pub const fn den(&self) -> NonZeroU32 ``` -------------------------------- ### Any::type_id Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Gets the TypeId of the Timebase type. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Returns - `TypeId`: The `TypeId` of the Timebase type. ``` -------------------------------- ### Any::type_id Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Gets the TypeId of a Timestamp. ```APIDOC ## Any::type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Returns - `TypeId`: The `TypeId` of the Timestamp. ``` -------------------------------- ### Interpolate Timestamp within TimeRange Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Linearly interpolates between the start and end timestamps of the TimeRange based on a factor `t`. `t = 0.0` returns the start, `t = 1.0` returns the end, and `t = 0.5` returns the midpoint. The factor `t` is clamped to the range [0.0, 1.0]. Rounds toward zero. ```rust pub const fn interpolate(&self, t: f64) -> Timestamp ``` -------------------------------- ### Get TimeRange Timebase Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns the shared Timebase associated with the TimeRange. ```rust pub const fn timebase(&self) -> Timebase ``` -------------------------------- ### Check if TimeRange is Instant Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns true if the start and end PTS values of the TimeRange are equal, indicating a degenerate instant range. ```rust pub const fn is_instant(&self) -> bool ``` -------------------------------- ### TimeRange::total_pts Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns the span in PTS units (end - start) in this timebase. Always non-negative. ```APIDOC ## TimeRange::total_pts ### Description Returns the span in PTS units (`end - start`) in this timebase. Always non-negative given the `start <= end` constructor invariant. Saturates at `i64::MAX` in the pathological case where `end - start` would overflow `i64` (e.g., `start = i64::MIN`, `end = i64::MAX`). ### Returns - `i64` - The total PTS span of the range. ``` -------------------------------- ### Calculate Total PTS Span Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Calculates the total span of the TimeRange in PTS units (end - start). This value is always non-negative due to the constructor invariant. It saturates at i64::MAX if the subtraction would overflow. ```rust pub const fn total_pts(&self) -> i64 ``` -------------------------------- ### Define TimeRange Struct Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Defines the TimeRange struct, which represents a half-open time range [start, end) in a given Timebase. It is used for detected events and ensures endpoints share the same Timebase. ```rust pub struct TimeRange { /* private fields */ } ``` -------------------------------- ### Initialize and compare mediatime types Source: https://docs.rs/mediatime/latest/mediatime/index.html Shows how to create Timebase, Timestamp, and TimeRange objects and demonstrates their value-based equality and duration calculations. Requires importing core types and mediatime primitives. ```rust use core::num::NonZeroU32; use core::time::Duration; use mediatime::{Timebase, Timestamp, TimeRange}; // FFmpeg-style rational timebases. let ms = Timebase::new(1, NonZeroU32::new(1000).unwrap()); let mpegts = Timebase::new(1, NonZeroU32::new(90_000).unwrap()); // Same instant in two different timebases — they compare equal. let a = Timestamp::new(1_000, ms); let b = Timestamp::new(90_000, mpegts); assert_eq!(a, b); assert_eq!(a.duration_since(&b), Some(Duration::ZERO)); // `av_rescale_q`-style conversion, rounding toward zero. assert_eq!(ms.rescale(500, mpegts), 45_000); // Frame rate helpers — treat `Timebase` as fps and count frames. let ntsc = Timebase::new(30_000, NonZeroU32::new(1001).unwrap()); assert_eq!(ntsc.frames_to_duration(30_000), Duration::from_secs(1001)); // A half-open [start, end) range with interpolation. let r = TimeRange::new(100, 500, ms); assert_eq!(r.interpolate(0.5).pts(), 300); assert_eq!(r.duration(), Duration::from_millis(400)); ``` -------------------------------- ### Convert duration to PTS Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Converts a Duration into the number of PTS units represented by this timebase, rounding towards zero. This is the inverse of multiplying a PTS value by the timebase to get seconds. Saturates at i64::MAX for extremely large durations and returns 0 if the timebase numerator is zero. ```rust pub const fn duration_to_pts(&self, d: Duration) -> i64 ``` -------------------------------- ### Get Duration from PTS Zero Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Calculates the Duration from PTS zero to the timestamp's current PTS, within its own timebase. Returns None if the timestamp's PTS is negative, as negative PTS does not have a direct Duration representation. ```rust pub const fn duration(&self) -> Option ``` -------------------------------- ### Timebase::new Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Creates a new Timebase with the given numerator and a non-zero denominator. ```APIDOC ## Timebase::new ### Description Creates a new `Timebase` with the given numerator and non-zero denominator. ### Signature ```rust pub const fn new(num: u32, den: NonZeroU32) -> Self ``` ``` -------------------------------- ### Compare floating-point seconds vs mediatime Timestamp Source: https://docs.rs/mediatime/latest/mediatime/index.html Demonstrates how mediatime::Timestamp provides exact equality semantics, unlike f64 seconds which suffer from rounding drift. ```rust f64 seconds: 0.1 + 0.2 == 0.3 → false mediatime::Timestamp: 100 ms == 9000 ticks @ 1/90000 → true ``` -------------------------------- ### impl Arbitrary for Timestamp (quickcheck) Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Provides methods for generating arbitrary Timestamp values using the quickcheck crate. ```APIDOC ## impl Arbitrary for Timestamp (quickcheck) ### Description Available on **crate feature `quickcheck`** only. ### Methods - `arbitrary(g: &mut Gen) -> Self`: Return an arbitrary value. - `shrink(&self) -> Box>`: Return an iterator of values that are smaller than itself. ``` -------------------------------- ### Create a new Timebase Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Creates a new Timebase with the given numerator and a non-zero denominator. Ensure the denominator is non-zero to avoid panics. ```rust pub const fn new(num: u32, den: NonZeroU32) -> Self ``` -------------------------------- ### CloneToUninit::clone_to_uninit Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Performs copy-assignment from self to dest (nightly-only). ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description 🔬This is a nightly-only experimental API. (`clone_to_uninit`) Performs copy-assignment from `self` to `dest`. ### Parameters - `dest`: A raw pointer to the destination memory. ``` -------------------------------- ### Arbitrary Value Generation (quickcheck crate) Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Provides methods for generating arbitrary Timestamp values using the `quickcheck` crate. This is useful for property-based testing. ```rust fn arbitrary(g: &mut Gen) -> Self ``` ```rust fn shrink(&self) -> Box> ``` -------------------------------- ### CloneToUninit::clone_to_uninit Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Performs copy-assignment from a Timestamp to uninitialized memory (nightly-only). ```APIDOC ## unsafe fn CloneToUninit::clone_to_uninit(&self, dest: *mut u8) ### Description 🔬This is a nightly-only experimental API. (`clone_to_uninit`) Performs copy-assignment from `self` to `dest`. ### Safety This function is unsafe and requires `dest` to be valid, uninitialized memory of the correct size. ### Parameters - `dest`: A raw pointer to the destination memory. ``` -------------------------------- ### Timebase::with_den Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Creates a new Timebase with the denominator updated. ```APIDOC ## Timebase::with_den ### Description Set the value of the denominator. ### Signature ```rust pub const fn with_den(self, den: NonZeroU32) -> Self ``` ``` -------------------------------- ### Generate arbitrary Timebase value (quickcheck) Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns an arbitrary Timebase value for use with the `quickcheck` crate. This implementation is available when the `quickcheck` crate feature is enabled. ```rust fn arbitrary(g: &mut Gen) -> Self ``` -------------------------------- ### From::from Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Creates a Timebase value from another value. ```APIDOC ## fn from(t: T) -> T ### Description Returns the argument unchanged. ### Parameters - `t`: The value to convert from. ### Returns - `T`: The converted value. ``` -------------------------------- ### TryFrom::try_from Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Attempts to convert a value into a Timebase, returning a Result. ```APIDOC ## fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion. ### Parameters - `value`: The value to attempt to convert. ### Returns - `Result>::Error>`: A Result containing the converted Timebase value or an error. ``` -------------------------------- ### Add mediatime to Cargo.toml Source: https://docs.rs/mediatime/latest/mediatime/index.html Specifies the mediatime crate version to be used in a Rust project's dependencies. ```toml [dependencies] mediatime = "0.1" ``` -------------------------------- ### Timebase::with_num Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Creates a new Timebase with the numerator updated. ```APIDOC ## Timebase::with_num ### Description Set the value of the numerator. ### Signature ```rust pub const fn with_num(self, num: u32) -> Self ``` ``` -------------------------------- ### Timebase::partial_cmp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Compares two Timebase values and returns an Option. ```APIDOC ## fn partial_cmp(&self, other: &Self) -> Option ### Description This method returns an ordering between `self` and `other` values if one exists. ### Parameters - `other`: The other Timebase value to compare against. ### Returns - `Option`: An `Ordering` if the values are comparable, `None` otherwise. ``` -------------------------------- ### Timebase::min Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Compares two Timebase values and returns the minimum. ```APIDOC ## fn min(self, other: Self) -> Self where Self: Sized ### Description Compares and returns the minimum of two values. ### Parameters - `other`: The other Timebase value to compare. ### Returns - `Self`: The minimum of the two Timebase values. ``` -------------------------------- ### Timestamp::partial_cmp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Compares two Timestamps and returns an Option. ```APIDOC ## Timestamp::partial_cmp(&self, other: &Self) -> Option ### Description This method returns an ordering between `self` and `other` values if one exists. ### Parameters - `other`: The other `Timestamp` to compare against. ### Returns - `Option`: An `Option` containing the `Ordering` if it exists, otherwise `None`. ``` -------------------------------- ### From::from Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Creates a Timestamp from another value. ```APIDOC ## From::from(t: T) -> T ### Description Returns the argument unchanged. ### Parameters - `t`: The value to convert from. ### Returns - `T`: The converted value. ``` -------------------------------- ### Arbitrary Value Generation (arbitrary crate) Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Provides methods for generating arbitrary Timestamp values using the `arbitrary` crate. This is useful for fuzzing and testing. ```rust fn arbitrary(u: &mut Unstructured<'a>) -> Result ``` ```rust fn arbitrary_take_rest(u: Unstructured<'a>) -> Result ``` ```rust fn size_hint(depth: usize) -> (usize, Option) ``` ```rust fn try_size_hint( depth: usize, ) -> Result<(usize, Option), MaxRecursionReached> ``` -------------------------------- ### TryInto::try_into Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Attempts to convert a Timestamp into another type. ```APIDOC ## TryInto::try_into(self) -> Result>::Error> ### Description Performs the conversion. ### Returns - `Result>::Error>`: A `Result` containing the converted value or an error. ``` -------------------------------- ### TryFrom::try_from Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Attempts to convert a value into a Timestamp. ```APIDOC ## TryFrom::try_from(value: U) -> Result>::Error> ### Description Performs the conversion. ### Parameters - `value`: The value to attempt to convert. ### Returns - `Result>::Error>`: A `Result` containing the converted Timestamp or an error. ``` -------------------------------- ### TryInto::try_into Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Attempts to convert a Timebase value into another type, returning a Result. ```APIDOC ## fn try_into(self) -> Result>::Error> ### Description Performs the conversion. ### Returns - `Result>::Error>`: A Result containing the converted value or an error. ``` -------------------------------- ### Shrink Timebase value (quickcheck) Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns an iterator of smaller Timebase values for use with the `quickcheck` crate. This implementation is available when the `quickcheck` crate feature is enabled. ```rust fn shrink(&self) -> Box> ``` -------------------------------- ### Arbitrary Value Generation for TimeRange Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Provides methods for generating arbitrary `TimeRange` values, useful for testing. These methods are available when the `arbitrary` or `quickcheck` crate features are enabled. ```rust fn arbitrary(u: &mut Unstructured<'a>) -> Result ``` ```rust fn arbitrary_take_rest(u: Unstructured<'a>) -> Result ``` ```rust fn size_hint(depth: usize) -> (usize, Option) ``` ```rust fn try_size_hint( depth: usize, ) -> Result<(usize, Option), MaxRecursionReached> ``` ```rust fn arbitrary(g: &mut Gen) -> Self ``` ```rust fn shrink(&self) -> Box> ``` -------------------------------- ### Rescale TimeRange to Target Timebase Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns a new TimeRange representing the same time span but rescaled to a different target Timebase. Rescaling is done by rounding towards zero, which may lose precision when moving to a coarser timebase. ```rust pub const fn rescale_to(self, target: Timebase) -> Self ``` -------------------------------- ### impl Arbitrary for Timestamp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Provides methods for generating arbitrary Timestamp values for testing purposes, available when the 'arbitrary' crate feature is enabled. ```APIDOC ## impl Arbitrary for Timestamp ### Description Available on **crate feature `arbitrary`** only. ### Methods - `arbitrary(u: &mut Unstructured<'a>) -> Result`: Generate an arbitrary value of `Self` from the given unstructured data. - `arbitrary_take_rest(u: Unstructured<'a>) -> Result`: Generate an arbitrary value of `Self` from the entirety of the given unstructured data. - `size_hint(depth: usize) -> (usize, Option)`: Get a size hint for how many bytes out of an `Unstructured` this type needs to construct itself. - `try_size_hint( depth: usize, ) -> Result<(usize, Option), MaxRecursionReached>`: Get a size hint for how many bytes out of an `Unstructured` this type needs to construct itself. ``` -------------------------------- ### Clone TimeRange Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Provides methods for cloning a `TimeRange` instance. `clone` returns a duplicate, while `clone_from` performs copy-assignment. ```rust fn clone(&self) -> TimeRange ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Borrow::borrow Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Immutably borrows the Timebase value. ```APIDOC ## fn borrow(&self) -> &T ### Description Immutably borrows from an owned value. ### Returns - `&T`: An immutable reference to the borrowed value. ``` -------------------------------- ### Borrow::borrow Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Immutably borrows a Timestamp. ```APIDOC ## Borrow::borrow(&self) -> &T ### Description Immutably borrows from an owned value. ### Returns - `&T`: An immutable reference to the borrowed value. ``` -------------------------------- ### TimeRange::with_timebase Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Sets the shared timebase and returns a new TimeRange. ```APIDOC ## TimeRange::with_timebase ### Description Sets the shared timebase and returns a new `TimeRange`. ### Parameters - **timebase** (Timebase) - The new timebase. ### Returns - `Self` - A new `TimeRange` with the updated timebase. ``` -------------------------------- ### Clone Timebase from source Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Performs copy-assignment from a source Timebase to this one. This is part of the `Clone` trait implementation. ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Rescale PTS using method form Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Rescales a presentation timestamp (PTS) from the current timebase (self) to a target timebase, rounding towards zero. This is the method form of `rescale_pts`. Panics if the target timebase numerator is zero. ```rust pub const fn rescale(&self, pts: i64, to: Self) -> i64 ``` -------------------------------- ### Timestamp::new Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Creates a new Timestamp with the given presentation timestamp (PTS) and timebase. ```APIDOC ## Timestamp::new ### Description Creates a new `Timestamp` with the given PTS and timebase. ### Signature ```rust pub const fn new(pts: i64, timebase: Timebase) -> Self ``` ``` -------------------------------- ### Timestamp::min Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Compares two Timestamps and returns the minimum value. ```APIDOC ## Timestamp::min(self, other: Self) -> Self ### Description Compares and returns the minimum of two values. ### Parameters - `other`: The other `Timestamp` to compare. ### Returns - `Self`: The minimum of the two `Timestamp` values. ``` -------------------------------- ### impl Clone for Timestamp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Provides standard cloning functionality for the Timestamp struct. ```APIDOC ## impl Clone for Timestamp ### Description Provides standard cloning functionality for the `Timestamp` struct. ### Methods - `clone(&self) -> Timestamp`: Returns a duplicate of the value. - `clone_from(&mut self, source: &Self)`: Performs copy-assignment from `source`. ``` -------------------------------- ### Set Timebase numerator Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns a new Timebase with the numerator updated. This is an immutable operation. ```rust pub const fn with_num(self, num: u32) -> Self ``` -------------------------------- ### BorrowMut::borrow_mut Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Mutably borrows a Timestamp. ```APIDOC ## BorrowMut::borrow_mut(&mut self) -> &mut T ### Description Mutably borrows from an owned value. ### Returns - `&mut T`: A mutable reference to the borrowed value. ``` -------------------------------- ### TimeRange::timebase Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns the shared timebase. ```APIDOC ## TimeRange::timebase ### Description Returns the shared timebase. ### Returns - `Timebase` - The timebase of the range. ``` -------------------------------- ### Timebase::den Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns the denominator of the Timebase. ```APIDOC ## Timebase::den ### Description Returns the denominator. ### Signature ```rust pub const fn den(&self) -> NonZeroU32 ``` ``` -------------------------------- ### Timebase::cmp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Compares two Timebase values and returns an Ordering. ```APIDOC ## fn cmp(&self, other: &Self) -> Ordering ### Description This method returns an `Ordering` between `self` and `other`. ### Parameters - `other`: The other Timebase value to compare against. ### Returns - `Ordering`: The ordering between the two values. ``` -------------------------------- ### impl Debug for Timestamp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Provides a Debug implementation for formatting Timestamp values for debugging. ```APIDOC ## impl Debug for Timestamp ### Description Provides a `Debug` implementation for formatting `Timestamp` values for debugging. ### Methods - `fmt(&self, f: &mut Formatter<'_>) -> Result`: Formats the value using the given formatter. ``` -------------------------------- ### Timebase::set_den Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Sets the denominator of the Timebase in place. ```APIDOC ## Timebase::set_den ### Description Set the value of the denominator in place. ### Signature ```rust pub const fn set_den(&mut self, den: NonZeroU32) -> &mut Self ``` ``` -------------------------------- ### Timestamp::cmp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Compares two Timestamps and returns an Ordering. ```APIDOC ## Timestamp::cmp(&self, other: &Self) -> Ordering ### Description This method returns an `Ordering` between `self` and `other`. ### Parameters - `other`: The other `Timestamp` to compare against. ### Returns - `Ordering`: The ordering between the two Timestamps. ``` -------------------------------- ### Timestamp::serialize Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Serializes a Timestamp to a Serde serializer. ```APIDOC ## Timestamp::serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> ### Description Serialize this value into the given Serde serializer. ### Parameters - `__serializer`: A Serde `Serializer`. ### Returns - `Result<__S::Ok, __S::Error>`: A `Result` indicating success or serialization error. ``` -------------------------------- ### Timebase::serialize Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Serializes a Timebase value into a Serde serializer. ```APIDOC ## fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where __S: Serializer ### Description Serialize this value into the given Serde serializer. ### Parameters - `__serializer`: The Serde serializer to use. ### Returns - `Result<__S::Ok, __S::Error>`: A Result indicating success or failure during serialization. ``` -------------------------------- ### Into::into Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Converts a Timestamp into another type. ```APIDOC ## Into::into(self) -> U ### Description Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ### Returns - `U`: The converted value. ``` -------------------------------- ### Semantic Comparison of Timestamps Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Compares two Timestamps based on the instant they represent, regardless of their timebases. For different timebases, it uses 128-bit cross-multiplication to avoid rounding errors. For identical timebases, it uses a fast path comparison. ```rust pub const fn cmp_semantic(&self, other: &Self) -> Ordering ``` -------------------------------- ### Into::into Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Converts a Timebase value into another type. ```APIDOC ## fn into(self) -> U where U: From ### Description Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ### Returns - `U`: The converted value. ``` -------------------------------- ### Set Timebase denominator Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns a new Timebase with the denominator updated. This is an immutable operation. ```rust pub const fn with_den(self, den: NonZeroU32) -> Self ``` -------------------------------- ### impl Default for Timestamp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Provides a default value for Timestamp, typically representing zero. ```APIDOC ## impl Default for Timestamp ### Description Provides a default value for `Timestamp`, typically representing zero. ``` -------------------------------- ### Timestamp::hash Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Feeds the Timestamp into a Hasher. ```APIDOC ## Timestamp::hash(&self, state: &mut H) ### Description Feeds this value into the given `Hasher`. ### Parameters - `state`: A mutable reference to a `Hasher`. ``` -------------------------------- ### Create New Timestamp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Creates a new Timestamp instance with a given PTS and timebase. This is a constant function, allowing creation at compile time. ```rust pub const fn new(pts: i64, timebase: Timebase) -> Self ``` -------------------------------- ### Convert frames to duration Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Treats the Timebase as a frame rate (frames per second) and calculates the Duration corresponding to a given number of frames. Note that frame rate and PTS timebase are conceptually different, often reciprocals. Panics if the timebase numerator is zero. ```rust pub const fn frames_to_duration(&self, frames: u32) -> Duration ``` -------------------------------- ### Timestamp::rescale_to Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Returns a new Timestamp representing the same instant but in a different target timebase. May lose precision. ```APIDOC ## Timestamp::rescale_to ### Description Returns a new `Timestamp` representing the same instant in a different timebase. Rounds toward zero via `Timebase::rescale_pts`; round-tripping through a coarser timebase can lose precision. ### Signature ```rust pub const fn rescale_to(self, target: Timebase) -> Self ``` ``` -------------------------------- ### Generate arbitrary Timebase from rest of data Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Generates an arbitrary Timebase value from the entirety of the unstructured data. This is available when the `arbitrary` crate feature is enabled. ```rust fn arbitrary_take_rest(u: Unstructured<'a>) -> Result ``` -------------------------------- ### Set PTS of Timestamp (New Instance) Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Returns a new Timestamp with the same timebase but a modified PTS value. The original Timestamp remains unchanged. ```rust pub const fn with_pts(self, pts: i64) -> Self ``` -------------------------------- ### Timebase::eq Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Tests if two Timebase values are equal. ```APIDOC ## fn eq(&self, other: &Self) -> bool ### Description Tests for `self` and `other` values to be equal, and is used by `==`. ### Parameters - `other`: The other Timebase value to compare against. ### Returns - `bool`: `true` if the values are equal, `false` otherwise. ``` -------------------------------- ### Saturating Subtract Duration from Timestamp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Returns a new Timestamp shifted backward by a given Duration, in the same timebase. If the subtraction would underflow (result less than i64::MIN), it saturates at i64::MIN. This is useful for initializing states that need to be ready immediately upon the first event. ```rust pub const fn saturating_sub_duration(self, d: Duration) -> Self ``` -------------------------------- ### BorrowMut::borrow_mut Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Mutably borrows the Timebase value. ```APIDOC ## fn borrow_mut(&mut self) -> &mut T ### Description Mutably borrows from an owned value. ### Returns - `&mut T`: A mutable reference to the borrowed value. ``` -------------------------------- ### Timebase::hash_slice Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Feeds a slice of Timebase values into a Hasher. ```APIDOC ## fn hash_slice(data: &[Self], state: &mut H) where H: Hasher, Self: Sized ### Description Feeds a slice of this type into the given `Hasher`. ### Parameters - `data`: A slice of Timebase values. - `state`: A mutable reference to the Hasher. ``` -------------------------------- ### Timebase::hash Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Feeds the Timebase value into a Hasher. ```APIDOC ## fn hash(&self, state: &mut H) ### Description Feeds this value into the given `Hasher`. ### Parameters - `state`: A mutable reference to the Hasher. ``` -------------------------------- ### Timebase::ne Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Tests if two Timebase values are not equal. ```APIDOC ## fn ne(&self, other: &Rhs) -> bool ### Description Tests for `!=`. The default implementation is almost always sufficient, and should not be overridden without very good reason. ### Parameters - `other`: The other value to compare against. ### Returns - `bool`: `true` if the values are not equal, `false` otherwise. ``` -------------------------------- ### Rescale PTS from one timebase to another Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Rescales a presentation timestamp (PTS) from a source timebase to a target timebase, rounding towards zero. This function uses a 128-bit intermediate to prevent overflow for typical video PTS ranges and saturates to i64::MIN or i64::MAX if the result exceeds i64's range. Panics if the target timebase numerator is zero. ```rust pub const fn rescale_pts(pts: i64, from: Self, to: Self) -> i64 ``` -------------------------------- ### Timebase::default Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns the default value for the Timebase type. ```APIDOC ## fn default() -> Self ### Description Returns the “default value” for a type. ### Returns - `Self`: The default value of the Timebase type. ``` -------------------------------- ### Timebase::max Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Compares two Timebase values and returns the maximum. ```APIDOC ## fn max(self, other: Self) -> Self where Self: Sized ### Description Compares and returns the maximum of two values. ### Parameters - `other`: The other Timebase value to compare. ### Returns - `Self`: The maximum of the two Timebase values. ``` -------------------------------- ### Format Timebase for debugging Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Formats the Timebase value for debugging output using the `Debug` trait. This allows the Timebase to be printed in a developer-friendly format. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### Timebase::le Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Tests if a Timebase value is less than or equal to another. ```APIDOC ## fn le(&self, other: &Rhs) -> bool ### Description Tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. ### Parameters - `other`: The other value to compare against. ### Returns - `bool`: `true` if `self` is less than or equal to `other`, `false` otherwise. ``` -------------------------------- ### Set Timebase numerator in place Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Sets the numerator of the Timebase in place. This is a mutable operation. ```rust pub const fn set_num(&mut self, num: u32) -> &mut Self ``` -------------------------------- ### Clone Timebase value Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns a duplicate of the Timebase value. This is a standard `Clone` trait implementation. ```rust fn clone(&self) -> Timebase ``` -------------------------------- ### TimeRange::set_timebase Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Sets the shared timebase in place and returns a mutable reference to self. ```APIDOC ## TimeRange::set_timebase ### Description Sets the shared timebase in place and returns a mutable reference to self. ### Parameters - **timebase** (Timebase) - The new timebase. ### Returns - `&mut Self` - A mutable reference to the `TimeRange`. ``` -------------------------------- ### Timebase::num Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Returns the numerator of the Timebase. ```APIDOC ## Timebase::num ### Description Returns the numerator. ### Signature ```rust pub const fn num(&self) -> u32 ``` ``` -------------------------------- ### Timestamp::eq Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Tests if two Timestamps are equal. ```APIDOC ## Timestamp::eq(&self, other: &Self) -> bool ### Description Tests for `self` and `other` values to be equal, and is used by `==`. ### Parameters - `other`: The other `Timestamp` to compare against. ### Returns - `bool`: `true` if the Timestamps are equal, `false` otherwise. ``` -------------------------------- ### Timebase::duration_to_pts Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Converts a Duration into PTS units for this Timebase, rounding towards zero. Saturates on overflow. ```APIDOC ## Timebase::duration_to_pts ### Description Converts a `Duration` into the number of PTS units this timebase represents, rounding toward zero. Inverse of “multiplying a PTS value by this timebase to get seconds”. Saturates at `i64::MAX` if the duration is absurdly large for this timebase. Returns `0` if `self.num() == 0` (a degenerate timebase). ### Signature ```rust pub const fn duration_to_pts(&self, d: Duration) -> i64 ``` ``` -------------------------------- ### Timebase struct definition Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Defines the Timebase struct, which represents a rational number for media timebases. ```rust pub struct Timebase { /* private fields */ } ``` -------------------------------- ### TimeRange::rescale_to Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns a new TimeRange representing the same span in a different timebase. ```APIDOC ## TimeRange::rescale_to ### Description Returns a new `TimeRange` representing the same span in a different timebase. Rescales both endpoints via `Timebase::rescale_pts` (rounds toward zero); round-tripping through a coarser timebase can lose precision. Because rescaling is monotonic, the `start <= end` invariant is preserved. ### Parameters - **target** (Timebase) - The target timebase to rescale to. ### Returns - `Self` - A new `TimeRange` in the target timebase. ``` -------------------------------- ### Timebase::clamp Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Restricts a Timebase value to a specified interval. ```APIDOC ## fn clamp(self, min: Self, max: Self) -> Self where Self: Sized ### Description Restrict a value to a certain interval. ### Parameters - `min`: The minimum allowed value. - `max`: The maximum allowed value. ### Returns - `Self`: The clamped Timebase value. ``` -------------------------------- ### Timestamp::max Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Compares two Timestamps and returns the maximum value. ```APIDOC ## Timestamp::max(self, other: Self) -> Self ### Description Compares and returns the maximum of two values. ### Parameters - `other`: The other `Timestamp` to compare. ### Returns - `Self`: The maximum of the two `Timestamp` values. ``` -------------------------------- ### Timestamp::hash_slice Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Feeds a slice of Timestamps into a Hasher. ```APIDOC ## Timestamp::hash_slice(data: &[Self], state: &mut H) ### Description Feeds a slice of this type into the given `Hasher`. ### Parameters - `data`: A slice of `Timestamp` values. - `state`: A mutable reference to a `Hasher`. ``` -------------------------------- ### Modify TimeRange Timebase Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Creates a new TimeRange with an updated shared timebase. Use `set_timebase` for in-place modification. ```rust pub const fn with_timebase(self, timebase: Timebase) -> Self ``` ```rust pub const fn set_timebase(&mut self, timebase: Timebase) -> &mut Self ``` -------------------------------- ### Generate arbitrary Timebase value Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Generates an arbitrary Timebase value from unstructured data. This is available when the `arbitrary` crate feature is enabled. ```rust fn arbitrary(u: &mut Unstructured<'a>) -> Result ``` -------------------------------- ### Timebase::set_num Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Sets the numerator of the Timebase in place. ```APIDOC ## Timebase::set_num ### Description Set the value of the numerator in place. ### Signature ```rust pub const fn set_num(&mut self, num: u32) -> &mut Self ``` ``` -------------------------------- ### TimeRange::with_end Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Sets the end PTS and returns a new TimeRange. ```APIDOC ## TimeRange::with_end ### Description Sets the end PTS and returns a new `TimeRange`. ### Parameters - **val** (i64) - The new end PTS value. ### Returns - `Self` - A new `TimeRange` with the updated end PTS. ``` -------------------------------- ### Timestamp::duration_since Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Calculates the elapsed Duration between two Timestamps, handling different timebases and potential overflow. ```APIDOC ## Timestamp::duration_since ### Description Returns the elapsed `Duration` from `earlier` to `self`, or `None` if `earlier` is after `self`. Works across different timebases. Computes the exact rational difference first using a common denominator, then truncates once when converting to nanoseconds for the returned `Duration`. If the result would exceed `Duration::MAX` (pathological: seconds don’t fit in `u64`), saturates to `Duration::MAX` rather than wrapping. ### Signature ```rust pub const fn duration_since(&self, earlier: &Self) -> Option ``` ``` -------------------------------- ### Timebase::lt Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Tests if a Timebase value is less than another. ```APIDOC ## fn lt(&self, other: &Rhs) -> bool ### Description Tests less than (for `self` and `other`) and is used by the `<` operator. ### Parameters - `other`: The other value to compare against. ### Returns - `bool`: `true` if `self` is less than `other`, `false` otherwise. ``` -------------------------------- ### Timestamp::timebase Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Returns the timebase associated with the timestamp. ```APIDOC ## Timestamp::timebase ### Description Returns the timebase of the timestamp. ### Signature ```rust pub const fn timebase(&self) -> Timebase ``` ``` -------------------------------- ### TimeRange::end Source: https://docs.rs/mediatime/latest/mediatime/struct.TimeRange.html Returns the end as a Timestamp. ```APIDOC ## TimeRange::end ### Description Returns the end as a `Timestamp`. ### Returns - `Timestamp` - The end timestamp. ``` -------------------------------- ### Set Timebase denominator in place Source: https://docs.rs/mediatime/latest/mediatime/struct.Timebase.html Sets the denominator of the Timebase in place. This is a mutable operation. ```rust pub const fn set_den(&mut self, den: NonZeroU32) -> &mut Self ``` -------------------------------- ### ToOwned::to_owned Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Creates an owned Timestamp from a borrowed one. ```APIDOC ## ToOwned::to_owned(&self) -> T ### Description Creates owned data from borrowed data, usually by cloning. ### Returns - `T`: An owned version of the Timestamp. ``` -------------------------------- ### Timestamp::pts Source: https://docs.rs/mediatime/latest/mediatime/struct.Timestamp.html Returns the presentation timestamp in units of its associated timebase. ```APIDOC ## Timestamp::pts ### Description Returns the presentation timestamp, in units of `Self::timebase`. To obtain a `Duration`, use `Self::duration_since` against a reference timestamp, or rescale via `Self::rescale_to`. ### Signature ```rust pub const fn pts(&self) -> i64 ``` ```