nautilus_common::clock

Trait Clock

source
pub trait Clock {
Show 13 methods // Required methods fn timestamp_ns(&self) -> UnixNanos; fn timestamp_us(&self) -> u64; fn timestamp_ms(&self) -> u64; fn timestamp(&self) -> f64; fn timer_names(&self) -> Vec<&str>; fn timer_count(&self) -> usize; fn register_default_handler(&mut self, callback: TimeEventCallback); fn set_time_alert_ns( &mut self, name: &str, alert_time_ns: UnixNanos, callback: Option<TimeEventCallback>, ); fn set_timer_ns( &mut self, name: &str, interval_ns: u64, start_time_ns: UnixNanos, stop_time_ns: Option<UnixNanos>, callback: Option<TimeEventCallback>, ); fn next_time_ns(&self, name: &str) -> UnixNanos; fn cancel_timer(&mut self, name: &str); fn cancel_timers(&mut self); // Provided method fn utc_now(&self) -> DateTime<Utc> { ... }
}
Expand description

Represents a type of clock.

§Notes

An active timer is one which has not expired (timer.is_expired == False).

Required Methods§

source

fn timestamp_ns(&self) -> UnixNanos

Returns the current UNIX timestamp in nanoseconds (ns).

source

fn timestamp_us(&self) -> u64

Returns the current UNIX timestamp in microseconds (μs).

source

fn timestamp_ms(&self) -> u64

Returns the current UNIX timestamp in milliseconds (ms).

source

fn timestamp(&self) -> f64

Returns the current UNIX timestamp in seconds.

source

fn timer_names(&self) -> Vec<&str>

Returns the names of active timers in the clock.

source

fn timer_count(&self) -> usize

Returns the count of active timers in the clock.

source

fn register_default_handler(&mut self, callback: TimeEventCallback)

Register a default event handler for the clock. If a Timer does not have an event handler, then this handler is used.

source

fn set_time_alert_ns( &mut self, name: &str, alert_time_ns: UnixNanos, callback: Option<TimeEventCallback>, )

Set a Timer to alert at a particular time. Optional callback gets used to handle generated events.

source

fn set_timer_ns( &mut self, name: &str, interval_ns: u64, start_time_ns: UnixNanos, stop_time_ns: Option<UnixNanos>, callback: Option<TimeEventCallback>, )

Set a Timer to start alerting at every interval between start and stop time. Optional callback gets used to handle generated event.

source

fn next_time_ns(&self, name: &str) -> UnixNanos

source

fn cancel_timer(&mut self, name: &str)

source

fn cancel_timers(&mut self)

Provided Methods§

source

fn utc_now(&self) -> DateTime<Utc>

Returns the current date and time as a timezone-aware DateTime<UTC>.

Implementors§