pub struct WeakPublisher<Message> { /* private fields */ }Expand description
A weak publisher republishes a Publisher only so long as that Publisher exists.
This type of publisher can be created by calling republish_weak() on a Publisher. The subscribers will close if the
Publisher is released even if the WeakPublisher still exists.
This is useful as a way to send messages to a stream without ‘owning’ it, where it’s acceptable for the messages to be dropped once the target has gone away (eg: messages to a window in a user interface might not longer be relevant once the window has closed)
Implementations§
Source§impl<Message: Clone> WeakPublisher<Message>
impl<Message: Clone> WeakPublisher<Message>
Sourcepub fn count_subscribers(&self) -> usize
pub fn count_subscribers(&self) -> usize
Counts the number of subscribers in this publisher
Trait Implementations§
Source§impl<Message: 'static + Send + Clone> MessagePublisher for WeakPublisher<Message>
impl<Message: 'static + Send + Clone> MessagePublisher for WeakPublisher<Message>
Source§fn subscribe(&mut self) -> Subscriber<Message>
fn subscribe(&mut self) -> Subscriber<Message>
Subscribes to this publisher
Subscribers only receive messages sent to the publisher after they are created.
Source§fn when_ready(&mut self) -> BoxFuture<'static, MessageSender<Message>>
fn when_ready(&mut self) -> BoxFuture<'static, MessageSender<Message>>
Reserves a space for a message with the subscribers, returning when it’s ready
Source§fn when_empty(&mut self) -> BoxFuture<'static, ()>
fn when_empty(&mut self) -> BoxFuture<'static, ()>
Waits until all subscribers have consumed all pending messages
Source§fn is_closed(&self) -> bool
fn is_closed(&self) -> bool
Returns true if this publisher is closed (will not publish any further messages to its subscribers)
Source§fn when_closed(&self) -> BoxFuture<'static, ()>
fn when_closed(&self) -> BoxFuture<'static, ()>
Future that returns when this publisher is closed