pub struct Diff(/* private fields */);
Expand description
The difference between two Time
s. Unlike std::time::Duration
, this
can be negative.
Implementations§
Source§impl Diff
impl Diff
Sourcepub fn as_audio_idx(&self, sample_rate: u32) -> isize
pub fn as_audio_idx(&self, sample_rate: u32) -> isize
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 scribble_curves::time::{ZERO, Time};
assert_eq!((ZERO - ZERO).as_audio_idx(44100), 0);
assert_eq!((Time::from_micros(1000000) - ZERO).as_audio_idx(44100), 44100);
assert_eq!((ZERO - Time::from_micros(1000000)).as_audio_idx(44100), -44100);
pub fn from_audio_idx(idx: i64, sample_rate: u32) -> Diff
pub const fn as_micros(self) -> i64
pub const fn from_micros(us: i64) -> Diff
Trait Implementations§
Source§impl AddAssign<Diff> for Time
impl AddAssign<Diff> for Time
Source§fn add_assign(&mut self, rhs: Diff)
fn add_assign(&mut self, rhs: Diff)
Performs the
+=
operation. Read moreSource§impl<'de> Deserialize<'de> for Diff
impl<'de> Deserialize<'de> for Diff
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Diff
impl Ord for Diff
Source§impl PartialOrd for Diff
impl PartialOrd for Diff
Source§impl SubAssign<Diff> for Time
impl SubAssign<Diff> for Time
Source§fn sub_assign(&mut self, rhs: Diff)
fn sub_assign(&mut self, rhs: Diff)
Performs the
-=
operation. Read moreimpl Copy for Diff
impl Eq for Diff
impl StructuralPartialEq for Diff
Auto Trait Implementations§
impl Freeze for Diff
impl RefUnwindSafe for Diff
impl Send for Diff
impl Sync for Diff
impl Unpin for Diff
impl UnwindSafe for Diff
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