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
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,16 @@ pub mod channel {
}
}

pub async fn closed(&mut self)
where
T: RpcMessage,
{
match self {
Sender::Tokio(tx) => tx.closed().await,
Sender::Boxed(sink) => sink.closed().await,
}
}

#[cfg(feature = "stream")]
pub fn into_sink(self) -> impl n0_future::Sink<T, Error = SendError> + Send + 'static
where
Expand Down Expand Up @@ -402,6 +412,9 @@ pub mod channel {
value: T,
) -> Pin<Box<dyn Future<Output = io::Result<bool>> + Send + '_>>;

/// Await the sender close
fn closed(&mut self) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>;

/// True if this is a remote sender
fn is_rpc(&self) -> bool;
}
Expand Down Expand Up @@ -1382,6 +1395,12 @@ pub mod rpc {
})
}

fn closed(&mut self) -> Pin<Box<dyn Future<Output = ()> + Send + '_>> {
Box::pin(async move {
self.send.stopped().await.ok();
})
}

fn is_rpc(&self) -> bool {
true
}
Expand Down