pub struct ClockApi<'a> { /* private fields */ }Expand description
User-facing clock API.
Implementations§
Source§impl<'a> ClockApi<'a>
impl<'a> ClockApi<'a>
Sourcepub fn timestamp_ns(&self) -> UnixNanos
pub fn timestamp_ns(&self) -> UnixNanos
Returns the current UNIX nanoseconds timestamp.
§Panics
Panics if the clock is already mutably borrowed.
Sourcepub fn timestamp_us(&self) -> u64
pub fn timestamp_us(&self) -> u64
Returns the current UNIX timestamp in microseconds.
§Panics
Panics if the clock is already mutably borrowed.
Sourcepub fn timestamp_ms(&self) -> u64
pub fn timestamp_ms(&self) -> u64
Returns the current UNIX timestamp in milliseconds.
§Panics
Panics if the clock is already mutably borrowed.
Sourcepub fn timestamp(&self) -> f64
pub fn timestamp(&self) -> f64
Returns the current UNIX timestamp in seconds.
§Panics
Panics if the clock is already mutably borrowed.
Sourcepub fn set_time_alert(
&self,
name: &str,
alert_time: DateTime<Utc>,
callback: Option<TimeEventCallback>,
allow_past: Option<bool>,
) -> Result<()>
pub fn set_time_alert( &self, name: &str, alert_time: DateTime<Utc>, callback: Option<TimeEventCallback>, allow_past: Option<bool>, ) -> Result<()>
Sourcepub fn set_time_alert_ns(
&self,
name: &str,
alert_time_ns: UnixNanos,
callback: Option<TimeEventCallback>,
allow_past: Option<bool>,
) -> Result<()>
pub fn set_time_alert_ns( &self, name: &str, alert_time_ns: UnixNanos, callback: Option<TimeEventCallback>, allow_past: Option<bool>, ) -> Result<()>
Sourcepub fn set_timer(
&self,
name: &str,
interval: Duration,
start_time: Option<DateTime<Utc>>,
stop_time: Option<DateTime<Utc>>,
callback: Option<TimeEventCallback>,
allow_past: Option<bool>,
fire_immediately: Option<bool>,
) -> Result<()>
pub fn set_timer( &self, name: &str, interval: Duration, start_time: Option<DateTime<Utc>>, stop_time: Option<DateTime<Utc>>, callback: Option<TimeEventCallback>, allow_past: Option<bool>, fire_immediately: Option<bool>, ) -> Result<()>
Sourcepub fn set_timer_ns(
&self,
name: &str,
interval_ns: u64,
start_time_ns: Option<UnixNanos>,
stop_time_ns: Option<UnixNanos>,
callback: Option<TimeEventCallback>,
allow_past: Option<bool>,
fire_immediately: Option<bool>,
) -> Result<()>
pub fn set_timer_ns( &self, name: &str, interval_ns: u64, start_time_ns: Option<UnixNanos>, stop_time_ns: Option<UnixNanos>, callback: Option<TimeEventCallback>, allow_past: Option<bool>, fire_immediately: Option<bool>, ) -> Result<()>
Sourcepub fn timer_names(&self) -> Vec<String>
pub fn timer_names(&self) -> Vec<String>
Sourcepub fn timer_count(&self) -> usize
pub fn timer_count(&self) -> usize
Sourcepub fn timer_exists(&self, name: &str) -> bool
pub fn timer_exists(&self, name: &str) -> bool
Sourcepub fn next_time_ns(&self, name: &str) -> Option<UnixNanos>
pub fn next_time_ns(&self, name: &str) -> Option<UnixNanos>
Returns the next trigger timestamp for the timer name.
§Panics
Panics if the clock is already mutably borrowed.
Sourcepub fn cancel_timer(&self, name: &str)
pub fn cancel_timer(&self, name: &str)
Sourcepub fn cancel_timers(&self)
pub fn cancel_timers(&self)
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ClockApi<'a>
impl<'a> !Send for ClockApi<'a>
impl<'a> !Sync for ClockApi<'a>
impl<'a> !UnwindSafe for ClockApi<'a>
impl<'a> Freeze for ClockApi<'a>
impl<'a> Unpin for ClockApi<'a>
impl<'a> UnsafeUnpin for ClockApi<'a>
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