Struct flo_stream::BlockingPublisher
source · pub struct BlockingPublisher<Message> { /* private fields */ }
Expand description
A blocking publisher is a publisher that blocks messages until it has enough subscribers
This is useful for cases where a publisher is being used asynchronously and wants to ensure that its messages are sent to at least one subscriber. Once the required number of subscribers is reached, this will not block again even if some subscribers are dropped.
Implementations§
source§impl<Message: Clone> BlockingPublisher<Message>
impl<Message: Clone> BlockingPublisher<Message>
sourcepub fn new(
required_subscribers: usize,
buffer_size: usize
) -> BlockingPublisher<Message>
pub fn new(
required_subscribers: usize,
buffer_size: usize
) -> BlockingPublisher<Message>
Creates a new blocking publisher
This publisher will refuse to receive any items until at least required_subscribers are connected. The buffer size indicates the number of queued items permitted per buffer.
sourcepub fn when_ready(&mut self) -> impl Future<Item = (), Error = Canceled>
pub fn when_ready(&mut self) -> impl Future<Item = (), Error = Canceled>
Returns a future that will complete when this publisher has enough subscribers
This is useful as a way to avoid blocking with wait_send
when setting up the publisher
Trait Implementations§
source§impl<Message: Clone> PublisherSink<Message> for BlockingPublisher<Message>
impl<Message: Clone> PublisherSink<Message> for BlockingPublisher<Message>
source§fn subscribe(&mut self) -> Subscriber<Message>
fn subscribe(&mut self) -> Subscriber<Message>
Creates a subscription to this publisher Read more
source§impl<Message: Clone> Sink for BlockingPublisher<Message>
impl<Message: Clone> Sink for BlockingPublisher<Message>
source§fn start_send(&mut self, item: Message) -> StartSend<Message, ()>
fn start_send(&mut self, item: Message) -> StartSend<Message, ()>
Begin the process of sending a value to the sink. Read more
source§fn poll_complete(&mut self) -> Poll<(), ()>
fn poll_complete(&mut self) -> Poll<(), ()>
Flush all output from this sink, if necessary. Read more
source§fn close(&mut self) -> Result<Async<()>, Self::SinkError>
fn close(&mut self) -> Result<Async<()>, Self::SinkError>
A method to indicate that no more values will ever be pushed into this
sink. Read more
source§fn wait(self) -> Wait<Self>where
Self: Sized,
fn wait(self) -> Wait<Self>where
Self: Sized,
Creates a new object which will produce a synchronous sink. Read more
source§fn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut>where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Self: Sized,
fn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut>where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Self: Sized,
Composes a function in front of the sink. Read more
source§fn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St>where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Self: Sized,
fn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St>where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Self: Sized,
Composes a function in front of the sink. Read more
source§fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::SinkError) -> E,
Self: Sized,
fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::SinkError) -> E,
Self: Sized,
Transforms the error returned by the sink.
source§fn sink_from_err<E>(self) -> SinkFromErr<Self, E>where
E: From<Self::SinkError>,
Self: Sized,
fn sink_from_err<E>(self) -> SinkFromErr<Self, E>where
E: From<Self::SinkError>,
Self: Sized,
Map this sink’s error to any error implementing
From
for this sink’s
Error
, returning a new sink. Read moresource§fn buffer(self, amt: usize) -> Buffer<Self>where
Self: Sized,
fn buffer(self, amt: usize) -> Buffer<Self>where
Self: Sized,
Adds a fixed-size buffer to the current sink. Read more
source§fn flush(self) -> Flush<Self>where
Self: Sized,
fn flush(self) -> Flush<Self>where
Self: Sized,
A future that completes when the sink has finished processing all
pending requests. Read more