pub struct Publisher<Message> { /* private fields */ }Expand description
A publisher represents a sink that sends messages to zero or more subscribers
Call subscribe() to create subscribers. Any messages sent to this sink will be relayed to all connected
subscribers. If the publisher is dropped, any connected subscribers will relay all sent messages and then
indicate that they have finished.
Implementations§
Source§impl<Message: Clone> Publisher<Message>
impl<Message: Clone> Publisher<Message>
Sourcepub fn new(buffer_size: usize) -> Publisher<Message>
pub fn new(buffer_size: usize) -> Publisher<Message>
Creates a new publisher with a particular buffer size
Sourcepub fn count_subscribers(&self) -> usize
pub fn count_subscribers(&self) -> usize
Counts the number of subscribers in this publisher
Sourcepub fn republish(&self) -> Self
pub fn republish(&self) -> Self
Creates a duplicate publisher that can be used to publish to the same streams as this object
Sourcepub fn republish_weak(&self) -> WeakPublisher<Message>
pub fn republish_weak(&self) -> WeakPublisher<Message>
Creates a duplicate publisher that can be used to publish to the same streams as this object
This creates a ‘weak’ publisher, which will stop republishing once all of the ‘strong’ publishers have been dropped.
Trait Implementations§
Source§impl<Message: 'static + Send + Clone> MessagePublisher for Publisher<Message>
impl<Message: 'static + Send + Clone> MessagePublisher for Publisher<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