mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
small refactoring (#6531)
This commit is contained in:
@ -74,10 +74,7 @@ impl TransportReceiverT for Receiver {
|
||||
|
||||
/// Returns a Future resolving when the server sent us something back.
|
||||
async fn receive(&mut self) -> Result<ReceivedMessage, Self::Error> {
|
||||
match self.inner.next().await {
|
||||
None => Err(IpcError::Closed),
|
||||
Some(val) => Ok(ReceivedMessage::Text(val?)),
|
||||
}
|
||||
self.inner.next().await.map_or(Err(IpcError::Closed), |val| Ok(ReceivedMessage::Text(val?)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -35,11 +35,10 @@ where
|
||||
|
||||
/// Polls to accept a new incoming connection to the endpoint.
|
||||
pub(crate) fn poll_accept(&mut self, cx: &mut Context<'_>) -> Poll<<Self as Stream>::Item> {
|
||||
let res = match ready!(self.poll_next_unpin(cx)) {
|
||||
None => Err(io::Error::new(io::ErrorKind::ConnectionAborted, "ipc connection closed")),
|
||||
Some(conn) => conn,
|
||||
};
|
||||
Poll::Ready(res)
|
||||
Poll::Ready(ready!(self.poll_next_unpin(cx)).map_or(
|
||||
Err(io::Error::new(io::ErrorKind::ConnectionAborted, "ipc connection closed")),
|
||||
|conn| conn,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user