pub struct TimeOffset(/* private fields */);Expand description
A signed span of time, stored as integer flicks.
Unlike Duration, an offset may be negative. It is the result of
Time - Time and the type of clip offsets and similar shifts. Arithmetic
panics on overflow, independently of the build profile.
Implementations§
Source§impl TimeOffset
impl TimeOffset
Sourcepub const fn from_ticks(ticks: i64) -> Self
pub const fn from_ticks(ticks: i64) -> Self
Constructs an offset without losing integer tick precision.
Sourcepub fn from_seconds(seconds: f64) -> Self
pub fn from_seconds(seconds: f64) -> Self
Rounds seconds to the nearest tick; halfway cases round away from zero.
§Panics
Panics for nonfinite input or a rounded result outside the signed range;
see Self::try_from_seconds.
Sourcepub fn try_from_seconds(seconds: f64) -> Result<Self, ValidationError>
pub fn try_from_seconds(seconds: f64) -> Result<Self, ValidationError>
Rounds seconds like Self::from_seconds, reporting nonfinite or out-of-range input.
Sourcepub fn as_seconds(self) -> f64
pub fn as_seconds(self) -> f64
Converts to floating-point seconds for animation mathematics.
Sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true when the offset moves toward earlier time.
Sourcepub const fn to_duration(self) -> Option<Duration>
pub const fn to_duration(self) -> Option<Duration>
Returns the offset as a duration, or None when it is negative.
Trait Implementations§
Source§impl Add for TimeOffset
impl Add for TimeOffset
Source§impl Add<TimeOffset> for Time
impl Add<TimeOffset> for Time
Source§impl AddAssign for TimeOffset
impl AddAssign for TimeOffset
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl AddAssign<TimeOffset> for Time
impl AddAssign<TimeOffset> for Time
Source§fn add_assign(&mut self, offset: TimeOffset)
fn add_assign(&mut self, offset: TimeOffset)
Performs the
+= operation. Read moreSource§impl Clone for TimeOffset
impl Clone for TimeOffset
impl Copy for TimeOffset
Source§impl Debug for TimeOffset
impl Debug for TimeOffset
Source§impl Default for TimeOffset
impl Default for TimeOffset
impl Eq for TimeOffset
Source§impl Hash for TimeOffset
impl Hash for TimeOffset
Source§impl Neg for TimeOffset
impl Neg for TimeOffset
Source§impl Ord for TimeOffset
impl Ord for TimeOffset
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for TimeOffset
impl PartialEq for TimeOffset
Source§impl PartialOrd for TimeOffset
impl PartialOrd for TimeOffset
impl StructuralPartialEq for TimeOffset
Source§impl Sub for TimeOffset
impl Sub for TimeOffset
Source§impl Sub<TimeOffset> for Time
impl Sub<TimeOffset> for Time
Source§impl SubAssign for TimeOffset
impl SubAssign for TimeOffset
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-= operation. Read moreSource§impl SubAssign<TimeOffset> for Time
impl SubAssign<TimeOffset> for Time
Source§fn sub_assign(&mut self, offset: TimeOffset)
fn sub_assign(&mut self, offset: TimeOffset)
Performs the
-= operation. Read moreAuto Trait Implementations§
impl Forget for TimeOffset
impl Freeze for TimeOffset
impl Move for TimeOffset
impl RefUnwindSafe for TimeOffset
impl Send for TimeOffset
impl Sync for TimeOffset
impl Unpin for TimeOffset
impl UnsafeUnpin for TimeOffset
impl UnwindSafe for TimeOffset
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