pub enum TimeExpr {
Fixed(SystemTime),
Now {
offset_secs: f64,
},
}Variants§
Implementations§
Source§impl TimeExpr
impl TimeExpr
Sourcepub fn resolve_at(&self, now: SystemTime) -> SystemTime
pub fn resolve_at(&self, now: SystemTime) -> SystemTime
Resolves self into a SystemTime, using now as a reference for offset expressions.
§Panics
This function may panic if the resulting point in time cannot be represented by the
underlying data structure. See TimeExpr::checked_resolve_at for a version without panic.
Sourcepub fn checked_resolve_at(&self, now: SystemTime) -> Option<SystemTime>
pub fn checked_resolve_at(&self, now: SystemTime) -> Option<SystemTime>
Resolves self into a SystemTime, using now as a reference for offset expressions.
If self is a TimeExpr::Now{offset_secs} and adding offset_secs to now results in a time
that would be outside the bounds of the underlying data structure, None is returned.
Sourcepub fn checked_add(&self, duration: f64) -> Option<Self>
pub fn checked_add(&self, duration: f64) -> Option<Self>
Adds duration to self, returning None if self is a Fixed(SystemTime) and adding the duration is not possible
because the result would be outside the bounds of the underlying data structure (see SystemTime::checked_add).
Otherwise returns Some(time_expr).
Sourcepub fn checked_sub(&self, duration: f64) -> Option<Self>
pub fn checked_sub(&self, duration: f64) -> Option<Self>
Subtracts duration from self, returning None if self is a Fixed(SystemTime) and subtracting the duration is not possible
because the result would be outside the bounds of the underlying data structure (see SystemTime::checked_sub).
Otherwise returns Some(time_expr).
Trait Implementations§
Source§impl From<SystemTime> for TimeExpr
impl From<SystemTime> for TimeExpr
Source§fn from(t: SystemTime) -> Self
fn from(t: SystemTime) -> Self
Source§impl TryFrom<TimeExpr> for SystemTime
impl TryFrom<TimeExpr> for SystemTime
impl Copy for TimeExpr
impl StructuralPartialEq for TimeExpr
Auto Trait Implementations§
impl Freeze for TimeExpr
impl RefUnwindSafe for TimeExpr
impl Send for TimeExpr
impl Sync for TimeExpr
impl Unpin for TimeExpr
impl UnsafeUnpin for TimeExpr
impl UnwindSafe for TimeExpr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more