Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ where
{
pub(crate) fn new(recv: C::RecvStream) -> (Self, UnwrapToPending<RpcServerError<C>>) {
let (error_send, error_recv) = oneshot::channel();
let error_recv = UnwrapToPending(error_recv);
let error_recv = UnwrapToPending(futures_lite::future::fuse(error_recv));
(Self(recv, Some(error_send), PhantomData), error_recv)
}
}
Expand Down Expand Up @@ -449,12 +449,13 @@ impl<C: ConnectionErrors> fmt::Display for RpcServerError<C> {
impl<C: ConnectionErrors> error::Error for RpcServerError<C> {}

/// Take an oneshot receiver and just return Pending the underlying future returns `Err(oneshot::Canceled)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Take an oneshot receiver and just return Pending the underlying future returns `Err(oneshot::Canceled)`
/// Take an oneshot receiver and just return Pending when the underlying future returns `Err(oneshot::Canceled)`

pub(crate) struct UnwrapToPending<T>(oneshot::Receiver<T>);
pub(crate) struct UnwrapToPending<T>(futures_lite::future::Fuse<oneshot::Receiver<T>>);

impl<T> Future for UnwrapToPending<T> {
type Output = T;

fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
// todo: use is_terminated from tokio 1.44 here to avoid the fused wrapper
match Pin::new(&mut self.0).poll(cx) {
Poll::Ready(Ok(x)) => Poll::Ready(x),
Poll::Ready(Err(_)) => Poll::Pending,
Expand Down
Loading