implement MessageResponse for Arc
This way a message can return an Arc which can be useful.
use futures::sync::oneshot::Sender as SyncSender;
use futures::Future;
use std::fmt;
+use std::sync::Arc;
use actor::{Actor, AsyncContext};
use address::Addr;
@@ -99,6 +100,18 @@ where
}
}
+impl<A, M, I: 'static> MessageResponse<A, M> for Arc<I>
+where
+ A: Actor,
+ M: Message<Result = Arc<I>>,
+{
+ fn handle<R: ResponseChannel<M>>(self, _: &mut A::Context, tx: Option<R>) {
+ if let Some(tx) = tx {
+ tx.send(self);
+ }
+ }
+}
+
impl<A, M, I: 'static> MessageResponse<A, M> for Option<I>
where
A: Actor,
