#[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>) {
IntervalFunc::new(Duration::from_millis(100), Self::tick)
.finish()
.spawn(context);
}
}
Creates a new IntervalFunc
with the given interval duration.
The type of item this stream will yield on success.
The type of error this stream may generate.
The actor within which this stream runs.
Converts a stream of type T
to a stream of type U
.
Converts a stream of error type T
to a stream of error type E
.
fn then<F, U>(self, f: F) -> StreamThen<Self, F, U> where F: FnMut(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> U, U: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
Chain on a computation for when a value is ready, passing the resulting item to the provided closure f
. Read more
fn and_then<F, U>(self, f: F) -> StreamAndThen<Self, F, U> where F: FnMut(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> U, U: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
Chain on a computation for when a value is ready, passing the successful results to the provided closure f
. Read more
fn fold<F, T, Fut>(self, init: T, f: F) -> StreamFold<Self, F, Fut, T> where F: FnMut(T, Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> Fut, Fut: IntoActorFuture<Actor = Self::Actor, Item = T>, Self::Error: From<Fut::Error>, Self: Sized, | [src] |
Execute an accumulating computation over a stream, collecting all the values into one final result. Read more
Converts a stream to a future that resolves when stream finishes.
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static