Skip to main content

ClockApi

Struct ClockApi 

Source
pub struct ClockApi<'a> { /* private fields */ }
Expand description

User-facing clock API.

Implementations§

Source§

impl<'a> ClockApi<'a>

Source

pub fn timestamp_ns(&self) -> UnixNanos

Returns the current UNIX nanoseconds timestamp.

§Panics

Panics if the clock is already mutably borrowed.

Source

pub fn timestamp_us(&self) -> u64

Returns the current UNIX timestamp in microseconds.

§Panics

Panics if the clock is already mutably borrowed.

Source

pub fn timestamp_ms(&self) -> u64

Returns the current UNIX timestamp in milliseconds.

§Panics

Panics if the clock is already mutably borrowed.

Source

pub fn timestamp(&self) -> f64

Returns the current UNIX timestamp in seconds.

§Panics

Panics if the clock is already mutably borrowed.

Source

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

Returns the current UTC time.

§Panics

Panics if the clock is already mutably borrowed.

Source

pub fn set_time_alert( &self, name: &str, alert_time: DateTime<Utc>, callback: Option<TimeEventCallback>, allow_past: Option<bool>, ) -> Result<()>

Sets a time alert delivered through the actor’s on_time_event callback.

§Errors

Returns an error if the alert cannot be scheduled.

§Panics

Panics if the clock is already borrowed.

Source

pub fn set_time_alert_ns( &self, name: &str, alert_time_ns: UnixNanos, callback: Option<TimeEventCallback>, allow_past: Option<bool>, ) -> Result<()>

Sets a time alert in UNIX nanoseconds delivered through the actor’s on_time_event callback.

§Errors

Returns an error if the alert cannot be scheduled.

§Panics

Panics if the clock is already borrowed.

Source

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<()>

Sets a timer delivered through the actor’s on_time_event callback.

§Errors

Returns an error if the timer cannot be scheduled.

§Panics

Panics if the clock is already borrowed.

Source

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<()>

Sets a timer in UNIX nanoseconds delivered through the actor’s on_time_event callback.

§Errors

Returns an error if the timer cannot be scheduled.

§Panics

Panics if the clock is already borrowed.

Source

pub fn timer_names(&self) -> Vec<String>

Returns active timer names.

§Panics

Panics if the clock is already mutably borrowed.

Source

pub fn timer_count(&self) -> usize

Returns the count of active timers.

§Panics

Panics if the clock is already mutably borrowed.

Source

pub fn timer_exists(&self, name: &str) -> bool

Returns whether the timer name exists.

§Panics

Panics if the clock is already mutably borrowed.

Source

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.

Source

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

Cancels the timer name.

§Panics

Panics if the clock is already borrowed.

Source

pub fn cancel_timers(&self)

Cancels all timers.

§Panics

Panics if the clock is already borrowed.

Trait Implementations§

Source§

impl<'a> Debug for ClockApi<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more