Skip to content

Commit

Permalink
impl FusedStream for MultiMessageStream
Browse files Browse the repository at this point in the history
  • Loading branch information
antonilol committed Oct 22, 2023
1 parent 34c78e1 commit 65a1d5a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/subscribe/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::{
pin::Pin,
task::{Context as AsyncContext, Poll},
};
use futures_util::stream::Fuse;
use futures_util::stream::{Fuse, FusedStream};
use zmq::Context as ZmqContext;

/// Stream that asynchronously produces [`Message`]s using a ZMQ subscriber.
Expand Down Expand Up @@ -88,6 +88,12 @@ impl Stream for MultiMessageStream {
}
}

impl FusedStream for MultiMessageStream {
fn is_terminated(&self) -> bool {
self.streams.iter().all(|stream| stream.is_terminated())
}
}

pub fn subscribe_multi_async(endpoints: &[&str]) -> Result<MultiMessageStream> {
let context = ZmqContext::new();
let mut res = MultiMessageStream::new(endpoints.len());
Expand Down

0 comments on commit 65a1d5a

Please sign in to comment.