pub trait ActorFuture {
type Item;
type Error;
type Actor: Actor;
fn poll(
&mut self,
srv: &mut Self::Actor,
ctx: &mut <Self::Actor as Actor>::Context
) -> Poll<Self::Item, Self::Error>;
fn map<F, U>(self, f: F) -> Map<Self, F>
where
F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> U,
Self: Sized,
{ ... }
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
where
F: FnOnce(Self::Error, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> E,
Self: Sized,
{ ... }
fn drop_err(self) -> DropErr<Self>
where
Self: Sized,
{ ... }
fn from_err<E: From<Self::Error>>(self) -> FromErr<Self, E>
where
Self: Sized,
{ ... }
fn then<F, B>(self, f: F) -> Then<Self, B, F>
where
F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B,
B: IntoActorFuture<Actor = Self::Actor>,
Self: Sized,
{ ... }
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>
where
F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B,
B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>,
Self: Sized,
{ ... }
fn timeout(self, timeout: Duration, err: Self::Error) -> Timeout<Self>
where
Self: Sized,
{ ... }
}
Trait for types which are a placeholder of a value that may become
available at some later point in time.
ActorFuture
is very similar to a regular Future
, only with subsequent combinator closures accepting the actor and its context, in addition to the result.
ActorFuture
allows for use cases where future processing requires access to the actor or its context.
Here is an example of a handler on a single actor, deferring work to another actor, and
then updating the initiating actor's state:
impl Message for SomeMessage {
type Result = ();
}
impl Handler<DeferredWork> for OriginalActor {
type Result = ResponseActFuture<Self, (), Error>;
fn handle(&mut self, _msg: Refresh, ctx: &mut Context<Self>) -> Self::Result {
let send_to_other = self.other_actor_addr
.send(OtherMessage::new())
.map_err(Error::from);
let update_self =
wrap_future::<_, Self>(send_to_other).map(|result, actor, _ctx| {
actor.inner_state.update_from(result);
});
Box::new(update_self);
}
}
See also into_actor, which provides future conversion using trait
The type of value that this future will resolved with if it is
successful.
The type of error that this future will resolve with if it fails in a
normal fashion.
The actor within which this future runs
Loading content...
Loading content...
fn map<F, U>(self, f: F) -> Map<Self, F> where
F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> U,
Self: Sized,
Map this future's result to a different type, returning a new future of
the resulting type.
Map this future's error to a different error, returning a new future.
Drop this future's error, returning a new future.
Map this future's error to any error implementing From
for
this future's Error
, returning a new future.
Chain on a computation for when a future finished, passing the result of
the future to the provided closure f
.
Execute another future after this one has resolved successfully.
Add timeout to futures chain.
err
value get returned as a timeout error.
Loading content...
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
Loading content...
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
type Item = T
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
type Item = T
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
type Item = U
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
fn then<F, B>(self, f: F) -> Then<Self, B, F> where F: FnOnce(Result<Self::Item, Self::Error>, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Actor = Self::Actor>, Self: Sized, | [src] |
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where F: FnOnce(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> B, B: IntoActorFuture<Error = Self::Error, Actor = Self::Actor>, Self: Sized, | [src] |
Loading content...