Publisher

Struct Publisher 

Source
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>

Source

pub fn new(buffer_size: usize) -> Publisher<Message>

Creates a new publisher with a particular buffer size

Source

pub fn count_subscribers(&self) -> usize

Counts the number of subscribers in this publisher

Source

pub fn republish(&self) -> Self

Creates a duplicate publisher that can be used to publish to the same streams as this object

Source

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> Drop for Publisher<Message>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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

Source§

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>>

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

Source§

type Message = Message

Source§

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

Publishes a message to the subscribers of this object

Auto Trait Implementations§

§

impl<Message> Freeze for Publisher<Message>

§

impl<Message> RefUnwindSafe for Publisher<Message>

§

impl<Message> Send for Publisher<Message>
where Message: Send,

§

impl<Message> Sync for Publisher<Message>
where Message: Send,

§

impl<Message> Unpin for Publisher<Message>

§

impl<Message> UnwindSafe for Publisher<Message>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SendStreamToPublisher for T

Source§

fn send_all<'a, SourceStream>( &'a mut self, stream: SourceStream, ) -> StreamPublisher<'a, T, SourceStream>
where SourceStream: 'a + Stream<Item = <T as MessagePublisher>::Message>,

Sends everything from a particular source stream to this publisher
Source§

impl<Publisher> ToPublisherSink for Publisher
where Publisher: MessagePublisher,

Source§

fn to_sink(self) -> PublisherSink<Publisher>

Converts this publisher into a futures Sink
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.