Skip to main content

CronActor

Trait CronActor 

Source
pub trait CronActor: Actor {
    // Required method
    fn task(
        &mut self,
        ctx: &mut Self::Context,
    ) -> impl Future<Output = Result<Duration, Self::Error>> + Send;
}
Available on crate feature cron only.
Expand description

Describes the behavior of an actor which can execute repetitive tasks.

Required Methods§

Source

fn task( &mut self, ctx: &mut Self::Context, ) -> impl Future<Output = Result<Duration, Self::Error>> + Send

Invoked to execute periodic tasks when an actor is running.

A Duration is returned to specify the interval of the next execution.

Notice the actor will not response to any messages during the execution of this function.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§