Struct actix::utils::IntervalFunc[][src]

#[must_use = "future do nothing unless polled"]pub struct IntervalFunc<A: Actor> { /* fields omitted */ }

An ActorStream that periodically runs a function in the actor's context.

Unless you specifically need access to the future, use Context::run_interval instead.

use std::time::Duration;
use actix::prelude::*;
use actix::utils::IntervalFunc;

struct MyActor;

impl MyActor {
    fn tick(&mut self, context: &mut Context<Self>) {
        println!("tick");
    }
}

impl Actor for MyActor {
   type Context = Context<Self>;

   fn started(&mut self, context: &mut Context<Self>) {
       // spawn an interval stream into our context
       IntervalFunc::new(Duration::from_millis(100), Self::tick)
           .finish()
           .spawn(context);
   }
}

Implementations

impl<A: Actor> IntervalFunc<A>[src]

pub fn new<F>(timeout: Duration, f: F) -> IntervalFunc<A> where
    F: FnMut(&mut A, &mut A::Context) + 'static, 
[src]

Creates a new IntervalFunc with the given interval duration.

Trait Implementations

impl<A: Actor> ActorStream for IntervalFunc<A>[src]

type Item = ()

The type of item this stream will yield on success.

type Actor = A

The actor within which this stream runs.

Auto Trait Implementations

impl<A> !RefUnwindSafe for IntervalFunc<A>[src]

impl<A> !Send for IntervalFunc<A>[src]

impl<A> !Sync for IntervalFunc<A>[src]

impl<A> Unpin for IntervalFunc<A>[src]

impl<A> !UnwindSafe for IntervalFunc<A>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.