MessagePublisher

Trait MessagePublisher 

Source
pub trait MessagePublisher
where 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§

Source

type Message: 'static + Send

Required Methods§

Source

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.

Source

fn when_ready(&mut self) -> BoxFuture<'static, MessageSender<Self::Message>>

Reserves a space for a message with the subscribers, returning when it’s ready

Source

fn when_empty(&mut self) -> BoxFuture<'static, ()>

Waits until all subscribers have consumed all pending messages

Source

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, ()>

Future that returns when this publisher is closed

Provided Methods§

Source

fn publish(&mut self, message: Self::Message) -> BoxFuture<'static, ()>

Publishes a message to the subscribers of this object

Implementors§

Source§

impl<Message: 'static + Send + Clone> MessagePublisher for BlockingPublisher<Message>

Source§

type Message = Message

Source§

impl<Message: 'static + Send + Clone> MessagePublisher for ExpiringPublisher<Message>

Source§

type Message = Message

Source§

impl<Message: 'static + Send + Clone> MessagePublisher for Publisher<Message>

Source§

type Message = Message

Source§

impl<Message: 'static + Send + Clone> MessagePublisher for WeakPublisher<Message>

Source§

type Message = Message

Source§

impl<Message: 'static + Send> MessagePublisher for SinglePublisher<Message>

Source§

type Message = Message