pub trait MessagePublisherwhere
Self: Send,{
type Message: 'static + Send;
// Required methods
fn subscribe(&mut self) -> Subscriber<Self::Message>;
fn when_ready(&mut self) -> BoxFuture<'static, MessageSender<Self::Message>>;
fn when_empty(&mut self) -> BoxFuture<'static, ()>;
fn is_closed(&self) -> bool;
fn when_closed(&self) -> BoxFuture<'static, ()>;
// Provided method
fn publish(&mut self, message: Self::Message) -> BoxFuture<'static, ()> { ... }
}Expand description
Trait that provides functions for publishing messages to subscribers
Required Associated Types§
Required Methods§
Sourcefn subscribe(&mut self) -> Subscriber<Self::Message>
fn subscribe(&mut self) -> Subscriber<Self::Message>
Creates a subscription to this publisher
Any future messages sent here will also be sent to this subscriber.
Sourcefn when_ready(&mut self) -> BoxFuture<'static, MessageSender<Self::Message>>
fn when_ready(&mut self) -> BoxFuture<'static, MessageSender<Self::Message>>
Reserves a space for a message with the subscribers, returning when it’s ready
Sourcefn when_empty(&mut self) -> BoxFuture<'static, ()>
fn when_empty(&mut self) -> BoxFuture<'static, ()>
Waits until all subscribers have consumed all pending messages
Sourcefn 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)
Sourcefn when_closed(&self) -> BoxFuture<'static, ()>
fn when_closed(&self) -> BoxFuture<'static, ()>
Future that returns when this publisher is closed