nautilus_common::clock

Trait Clock

Source
pub trait Clock {
Show 14 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 get_handler(&self, event: TimeEvent) -> TimeEventHandlerV2; 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 get_handler(&self, event: TimeEvent) -> TimeEventHandlerV2

Get handler for TimeEvent

Note: Panics if the event does not have an associated handler

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

Returns the time interval in which the timer name is triggered.

If the timer doesn’t exist 0 is returned.

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§