use std::task::{Context, Poll}; use futures::Future; use pin_project::pin_project; use tokio::sync::oneshot; use crate::actor::ActorError; #[pin_project(project = ActorFutureProjection)] pub struct ActorFuture { #[pin] pub(crate) inner: oneshot::Receiver>, } impl Future for ActorFuture where E: From, { type Output = Result; fn poll(self: std::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.project().inner.poll(cx) { Poll::Ready(Ok(res)) => Poll::Ready(res), Poll::Ready(Err(_)) => Poll::Ready(Err(ActorError::ActorHungUp.into())), Poll::Pending => Poll::Pending, } } }