Skip to content

Commit

Permalink
Format document
Browse files Browse the repository at this point in the history
  • Loading branch information
haixuanTao committed Dec 7, 2023
1 parent 1ad35fa commit 8648ce9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions apis/rust/node/src/event_stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,15 @@ impl EventStream {
pub async fn recv_async(&mut self) -> Option<Event> {
self.receiver.next().await.map(Self::convert_event_item)
}

pub async fn recv_async_timeout(&mut self, dur: Duration) -> Option<Event> {
let next_event = match select(Delay::new(dur), self.receiver.next()).await {
Either::Left((_elapsed, _)) => {
Some(EventItem::TimeoutError(eyre!("Receiver timed out")))
}
Either::Right((event, _)) => event,
};
next_event
.map(Self::convert_event_item)
Either::Left((_elapsed, _)) => {
Some(EventItem::TimeoutError(eyre!("Receiver timed out")))
}
Either::Right((event, _)) => event,
};
next_event.map(Self::convert_event_item)
}

fn convert_event_item(item: EventItem) -> Event {
Expand Down

0 comments on commit 8648ce9

Please sign in to comment.