Struct scribl_curves::TimeDiff[][src]

pub struct TimeDiff(_);

The difference between two Times. Unlike std::time::Duration, this can be negative.

Implementations

impl TimeDiff[src]

pub const ZERO: TimeDiff[src]

pub fn as_audio_idx(&self, sample_rate: u32) -> isize[src]

Interpreting self as the offset from the beginning of an audio buffer, return the corresponding index into that buffer. Note that the return value is signed, because a negative offset from the beginning of an audio buffer corresponds to a negative index.

Examples

use scribl_curves::Time;
assert_eq!((Time::ZERO - Time::ZERO).as_audio_idx(44100), 0);
assert_eq!((Time::from_micros(1000000) - Time::ZERO).as_audio_idx(44100), 44100);
assert_eq!((Time::ZERO - Time::from_micros(1000000)).as_audio_idx(44100), -44100);

pub fn from_audio_idx(idx: i64, sample_rate: u32) -> TimeDiff[src]

pub const fn as_micros(self) -> i64[src]

pub const fn from_micros(us: i64) -> TimeDiff[src]

Trait Implementations

impl Add<TimeDiff> for Time[src]

type Output = Time

The resulting type after applying the + operator.

impl Add<TimeDiff> for TimeDiff[src]

type Output = TimeDiff

The resulting type after applying the + operator.

impl AddAssign<TimeDiff> for Time[src]

impl Clone for TimeDiff[src]

impl Copy for TimeDiff[src]

impl Data for TimeDiff[src]

impl Debug for TimeDiff[src]

impl Default for TimeDiff[src]

impl<'de> Deserialize<'de> for TimeDiff[src]

impl Eq for TimeDiff[src]

impl Hash for TimeDiff[src]

impl Ord for TimeDiff[src]

impl PartialEq<TimeDiff> for TimeDiff[src]

impl PartialOrd<TimeDiff> for TimeDiff[src]

impl Serialize for TimeDiff[src]

impl StructuralEq for TimeDiff[src]

impl StructuralPartialEq for TimeDiff[src]

impl Sub<TimeDiff> for TimeDiff[src]

type Output = TimeDiff

The resulting type after applying the - operator.

impl Sub<TimeDiff> for Time[src]

type Output = Time

The resulting type after applying the - operator.

impl SubAssign<TimeDiff> for Time[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AnyEq for T where
    T: PartialEq<T> + Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.