pub struct SinglePublisher<Message> { /* private fields */ }Expand description
A single publisher is a publisher that sends each message to only a single subscriber rather than all of them
This is useful for scheduling messages on the first available worker.
Implementations§
Source§impl<Message> SinglePublisher<Message>
impl<Message> SinglePublisher<Message>
Sourcepub fn new(buffer_size: usize) -> SinglePublisher<Message>
pub fn new(buffer_size: usize) -> SinglePublisher<Message>
Creates a new single publisher, which will buffer the specified number of messages
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> Drop for SinglePublisher<Message>
impl<Message> Drop for SinglePublisher<Message>
Source§impl<Message: 'static + Send> MessagePublisher for SinglePublisher<Message>
impl<Message: 'static + Send> MessagePublisher for SinglePublisher<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
type Message = Message
Auto Trait Implementations§
impl<Message> Freeze for SinglePublisher<Message>
impl<Message> RefUnwindSafe for SinglePublisher<Message>
impl<Message> Send for SinglePublisher<Message>where
Message: Send,
impl<Message> Sync for SinglePublisher<Message>where
Message: Send,
impl<Message> Unpin for SinglePublisher<Message>
impl<Message> UnwindSafe for SinglePublisher<Message>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> SendStreamToPublisher for Twhere
T: MessagePublisher,
impl<T> SendStreamToPublisher for Twhere
T: MessagePublisher,
Source§fn send_all<'a, SourceStream>(
&'a mut self,
stream: SourceStream,
) -> StreamPublisher<'a, T, SourceStream> ⓘ
fn send_all<'a, SourceStream>( &'a mut self, stream: SourceStream, ) -> StreamPublisher<'a, T, SourceStream> ⓘ
Sends everything from a particular source stream to this publisher
Source§impl<Publisher> ToPublisherSink for Publisherwhere
Publisher: MessagePublisher,
impl<Publisher> ToPublisherSink for Publisherwhere
Publisher: MessagePublisher,
Source§fn to_sink(self) -> PublisherSink<Publisher>
fn to_sink(self) -> PublisherSink<Publisher>
Converts this publisher into a futures Sink